Update Field In Sales Header after record been imported?

RikarddoRikarddo Member Posts: 80
edited 2018-01-19 in NAV Three Tier

I have a process where i import one Sales Order from SalesForce to table Sales Header.
After the importation, it is possible to Update the Gen. Bus. Posting Group depending of the location?

For Example
IF "Sales Header"."Location Code"='MAI-AM' THEN
    "Sales Header"."Gen. Bus. Posting Group"='AMOSTRAS'
    "Sales Header".Modify;

I tried to use this code on the table, but when i send the sales order from Sales Force to NAV it says an error where it sayd the Document Header No. does not exist.

Should this code been written in the table or ?!

Thanks for the help

Just a note
I Have this code in the XML Port

<Sales Line> - Import::OnAfterModifyRecord()
//"<Sales Line>".VALIDATE("<Sales Line>"."No.");

   "<Sales Line>".DELETE(TRUE);

location.GET("<Sales Line>"."Location Code");
IF location.Amostras THEN
 "<Sales Line>".VALIDATE(Oferta,"<Sales Line>".Oferta::Amostra);
 "<Sales Line>".MODIFY;
 "<Sales Line>".AutoReserve;

Can i from here update Sales Header?

Best Answer


  • Options
    RikarddoRikarddo Member Posts: 80
    ratnesh272 wrote: »
    You can take one variable for Gen. Bus. Posting Group and write code to update it in XMLPort. You can write code on "Import::OnAfterAssignVariable()".

    Let us know if it works.


    Thanks for the help

    Wrote this code in Sales Header - Import::OnAfterInsertRecord() and it worked just fine!
    IF "Sales Header"."Location Code"='MAI-AM' THEN
       "Sales Header"."Gen. Bus. Posting Group":='AMOSTRAS';
        "Sales Header".MODIFY;
    //roliveira 2018-19-01 end

Sign In or Register to comment.