Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Update field in Sales Header after Sales Order been imported

(0) ShareShare
ReportReport
Posted on by 271

Hello,

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

*This post is locked for comments

  • Rikarddo Profile Picture
    Rikarddo 271 on at
    RE: Update field in Sales Header after Sales Order been imported

    Thanks Jonathan Archer, it worked just did as you said

    location.GET("<Sales Line>"."Location Code");
    IF location.Amostras THEN BEGIN
     "<Sales Line>".VALIDATE(Oferta,"<Sales Line>".Oferta::Amostra);
     "<Sales Line>".MODIFY;
    
    SalesHeader.GET("<Sales Line>"."Document Type","<Sales Line>"."Document No.");
    SalesHeader."Gen. Bus. Posting Group" := 'AMOSTRAS';
    salesheader.MODIFY;
    END;
    "<Sales Line>".AutoReserve;

    Thanks!

  • Verified answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: Update field in Sales Header after Sales Order been imported

    Check If fields "document type" and "document no." have values in record "sales line". If the fields are empty, then the sales line record is not imported correctly. If values are ok add following code after your code:

    Salesheader.get(salesline."Document type",salesline."document no.");

    salesheader."gen. bus. posting group" := ...

    Etc.

    Add variable Salesheader to the local variables: Type rec, sales header. That means to declare a variable.

  • Rikarddo Profile Picture
    Rikarddo 271 on at
    RE: Update field in Sales Header after Sales Order been imported

    What do you mean? 

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 60,157 Super User 2025 Season 1 on at
    RE: Update field in Sales Header after Sales Order been imported

    Did you declare Sales Header variable and get it?

    you can also use Rec instead Sales Header

    no need to modify also

  • Rikarddo Profile Picture
    Rikarddo 271 on at
    RE: Update field in Sales Header after Sales Order been imported

    In Gen. Bus. Posting Group - OnValidate()

    But i Have this code in the XML Port

    <Sales Line> - Import::OnAfterModifyRecord()
    //"<Sales Line>".VALIDATE("<Sales Line>"."No.");
    
    IF  TipoOper='DELETE' THEN
    BEGIN
       "<Sales Line>".DELETE(TRUE);
    END
    ELSE
    
    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?


  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 60,157 Super User 2025 Season 1 on at
    RE: Update field in Sales Header after Sales Order been imported

    where exactly did you write above code?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans