Select Order Adress

elToritoelTorito Member Posts: 191
I Make a new Order. I Select "Sell-to Customer No."
(This Customer has various Ship-to Adress List), when I Press Enter it will open a Form where i can select a "Ship To Adress".

My question is what must i do for make similar proces in Purchases & Payables, when i make new Order i select the "Buy from Vendor No."
When i press Enter i would that open a form automatically so i can select Order Adresses (if the vendor have one or more Order Adresses).

Actually we must go to the Field "Order Address Code" and Select the "Order Adress", but our sales persons forget frequently fill out this field.

Thanks.
(Oo)=*=(oO)

Comments

  • Dean_AxonDean_Axon Member Posts: 193
    Hi Eltorito,

    I dont know the functionality in Standard that you are asking about, but what you are trying to do sounds simple enough. :D

    OnAfterValidate trigger on the form of the field that you are entering (in your case "Buy From Vendor No.") enter the following code:
    Create variables:(global or local it does not matter)
    Vendship     Rec      Order Address (t224)
    VendForm   Form     Order Address List (F369)
    
    Code:
    VendShip.Setrange("Vendor No.","Buy From Vendor No.");
    IF VendShip.COUNT>1 THEN BEGIN
      VendForm.LOOKUPMODE(TRUE);
      VendForm.RUNMODAL;
    END;  
    

    That is the code for running the form, but I would assume that you dont want to stop there. So, the next part is to GET the record and paste it back to the "Order Address Code".

    Your code could now look something like this:
    Create one more variable (try to be consistent.  if you created locals, make another local etc.)
    CurrVendship     Rec      Order Address (t224)
    
    
    VendShip.SETRANGE("Vendor No.","Buy-from Vendor No.");
    IF VendShip.COUNT>1 THEN BEGIN
      VendForm.LOOKUPMODE(TRUE);
      VendForm.SETTABLEVIEW(VendShip);
      IF VendForm.RUNMODAL=ACTION::LookupOK THEN BEGIN
        VendForm.GETRECORD(CurrVendShip);
        VALIDATE("Order Address Code",CurrVendShip.Code);
      END;
    END;
    

    That should give you a solution that works. Ideally it should be done at table level, but I didn't have time to debug it :oops:

    Hope it helps :D

    Dean
    Remember: Keep it simple
  • elToritoelTorito Member Posts: 191
    Hello Dean,

    In the Table 38 Purchase Header in the OnValidate Trigger from "Buy-Form Vendor No." i will be put this code and then it seem like to work so i would it:
    IF ("Order Address Code" = '') AND (CurrFieldNo <> 0) THEN BEGIN
      Vendship.RESET;
      Vendship.SETRANGE("Vendor No.", "Buy-from Vendor No.");
      IF Vendship.FIND('-') THEN BEGIN
        CLEAR(VendShipForm);
        COMMIT;
        VendShipForm.SETTABLEVIEW(Vendship);
        VendShipForm.LOOKUPMODE(TRUE);
        IF VendShipForm.RUNMODAL=ACTION::LookupOK THEN BEGIN
          VendShipForm.GETRECORD(Vendship);
          VALIDATE("Order Address Code", Vendship.Code);
        END;
      END;
    END;
    

    Thanks for You Help !! :D
    (Oo)=*=(oO)
  • Dean_AxonDean_Axon Member Posts: 193
    anytime ,Glad to help :D:D
    Remember: Keep it simple
Sign In or Register to comment.