Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Process report to update the data in other page

(1) ShareShare
ReportReport
Posted on by 1,865

Dear Experts,

I want to make a process report to fill the "Customer No." and its "Customer Name" in Opportunities table. In Opportunities table there have a field "Sales Order No.", which is coming from "Sales Header" table. Every Opportunities No. is linked with "Sales Header" table, there have a field name is "Opportunities No". Please give some idea to do it.

*This post is locked for comments

  • Suggested answer
    Guillem Padilla Profile Picture
    Guillem Padilla 425 on at
    RE: Process report to update the data in other page

    Hi,

    Please, check those sales documents in Sales header, do they have Sell-to... fields with data?

    If not, you have to link the Contact No. with the Customer to get Customer info

  • manish.yadav Profile Picture
    manish.yadav 1,865 on at
    RE: Process report to update the data in other page

    I have write the same code in my process report as you suggested but still not updated customer and its code in Opportunity table

    5875.Untitled.png

  • Suggested answer
    Guillem Padilla Profile Picture
    Guillem Padilla 425 on at
    RE: Process report to update the data in other page

    Hi,

    There are some mistakes, I will explain you:

    I see that you do not have a field named "Sales Order No." (which you said in the first question), so you are using the standard, in this case, Opportunity table works with multiple document types (Field "Sales Document Type"), you should filter it too.

    You should not call FINDSET on Opportunity record, but SalesHeader, because you want to retrieve SalesHeader records

    You really do not have to call FINDSET, because an opportunity is linked to 1 Document, so you do not need to loop in SalesHeader on each Opportunity record...

    Here is a example code, it should works:

    Opportunity - OnAfterGetRecord()
    CASE "Sales Document Type" OF "Sales Document Type"::" " : BEGIN //Code if an opportunity is not linked, if nothing leave it blank or delete the statement END; "Sales Document Type"::Order: BEGIN IF SalesHeader.GET(SalesHeader."Document Type"::Order,Opportunity."Sales Document No.") THEN BEGIN "Customer No." := SalesHeader."Sell-to Customer No."; "Customer Name" := SalesHeader."Sell-to Customer Name"; MODIFY; END; END; "Sales Document Type"::Quote: BEGIN IF SalesHeader.GET(SalesHeader."Document Type"::Quote,Opportunity."Sales Document No.") THEN BEGIN "Customer No." := SalesHeader."Sell-to Customer No."; "Customer Name" := SalesHeader."Sell-to Customer Name"; MODIFY; END; END; "Sales Document Type"::"Posted Invoice": BEGIN //Code if an opportunity is linked with a Posted Invoice, if nothing leave it blank or delete the statement //This document type is linked to Sales Invoice Header table (112) instead of Sales Header (36) END; END;


    If you declared SalesHeader as a local variable, you do not need to RESET it every time, the local variables are loaded into the memory at the beginning and are deleted when the function / trigger finishes, OnAfterGetRecord is an trigger that runs in a loop until there are no more records, therefore, each execution of the trigger represents a different call

  • manish.yadav Profile Picture
    manish.yadav 1,865 on at
    RE: Process report to update the data in other page

    Thank you for your fast reply. I have already tried with the below code

    Opportunity - OnAfterGetRecord()

    SalesHeader.RESET();

    SalesHeader.SETRANGE("No.",Opportunity."Sales Document No.");

    IF Opportunity.FINDSET THEN BEGIN

      REPEAT

         Opportunity.Customer := SalesHeader."Sell-to Customer No.";

         Opportunity.Name := SalesHeader."Sell-to Customer Name";

         Opportunity.MODIFY;

      UNTIL Opportunity.NEXT=0;

    END;

    But there have no effect in Opportunity table. Please suggest me.

  • Suggested answer
    Guillem Padilla Profile Picture
    Guillem Padilla 425 on at
    RE: Process report to update the data in other page

    Hi,

    Assuming that you have this fields in Opportunity table, since the standard works with contacts and more document types.

    You can set Opportunity table as Dataitem

    In OnAfterGetRecord trigger create a local variable Record (Sales Header), and link Opportunity with Sales Header, an example:

    Opportunity - OnAfterGetRecord ()
    
    IF SalesHeader.GET(SalesHeader."Document Type"::Order,"Sales Order No.") THEN BEGIN
      "Customer No." := SalesHeader."Sell-to Customer No.";
      "Customer Name" := SalesHeader."Sell-to Customer Name";
      MODIFY;
    END;

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

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,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans