web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Not Getting Po No value

(0) ShareShare
ReportReport
Posted on by 3,099

Hi

   I have below code . On basis of condition sometimes i have to get values in Purch Invoice Header . Sometimes from Purch Inv Line. Getting values of all variables in both cases , but getting PO NO value in 1 case only.

Variables are defined in Purch Invoice Header Data Item only.

When i define PO NO in Purch Invoice Header Data Item then i get value in Purch Invoice Header only.

When i define PO No in Purch Invoice Line then i get value in Purch Invoice Line only.

When i put message then it display PO NO value in both cases. Only not showing in Dataset generated.

Thanks

*This post is locked for comments

I have the same question (0)
  • mmv Profile Picture
    11,471 on at

    Could you share the code?

  • jsshivalik Profile Picture
    3,099 on at

    Hi

      Forgot to upload. Will do it today.

    Thanks

  • jsshivalik Profile Picture
    3,099 on at

    Hi

     Below is the code . PRcpt is Record SubType of Purch. Rcpt. Header.

    Purch. Inv. Header - OnAfterGetRecord()

    PILine.SETFILTER("Document No.",'%1',"No.");

    IF("GRN No." <> '') THEN BEGIN

    PRcptHdr.SETRANGE("GRN No.","GRN No.");

    IF PRcptHdr.FINDFIRST THEN BEGIN

     RecpNo := PRcptHdr."No.";

     "PO No" := PRcptHdr."Order No.";

     "PO Dt" := PRcptHdr."Order Date";

    END;

    Purch. Inv. Line - OnAfterGetRecord()

    IF("Receipt No." <> '') THEN BEGIN

    PRcpt.SETRANGE("No.","Receipt No.");

    IF PRcpt.FINDFIRST THEN BEGIN

     RecpNo := PRcpt."No.";

     "PO No" := PRcpt."Order No.";

     "PO Dt" := PRcpt."Order Date";

    END;

    Thanks

  • mmv Profile Picture
    11,471 on at

    Are "PO No", RecpNo and "PO Dt" variable in your above code?

    Are you simply aiming at getting the "Order No" and "Order Date" of the related Purchase Order?

  • jsshivalik Profile Picture
    3,099 on at

    Yes. They are variables. I am confused why only P.O No value is not coming whereas all other values are coming.

    Thanks

  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    Is there any custom field with the same name (P.O No) in those tables ? Try to change the variable name to something different and try.

  • mmv Profile Picture
    11,471 on at

    You may write something like as below:-

    Purch. Inv. Header - OnAfterGetRecord()

    "PO No" := "Order No.";

    "PO Dt" := "Order Date";

    After this you have write another code to get the "Order No." and "Order Date" base on the related "Receipt No." and overwrite them onto "PO No" and "PO Dt";

    In order to get this, you may refer the code on the 139 "Posted Purch. Invoice Subform" -> Actions - "Item Receipt &Lines".  Once you follow that, you may get "Receipt No.", based on that Receipt No, you can get the "Order No." and "Order Date" from "Purch. Rcpt. Line" table.

    You have to use same code from "Item Receipt &Lines" on the "Purch. Inv. Line" - OnAfterGetRecord trigger too.

  • jsshivalik Profile Picture
    3,099 on at

    Hi

     When i print variable value "PO No" in Purch Inv Header then it shows value. When is display message in Purch Inv Line then it shows blank. Since it is global value it should not show value in Lines also . Other variable are showing

    Thanks

  • mmv Profile Picture
    11,471 on at

    If your code is on the "Purch. Inv. Line" - "OnAfterGetRecord" trigger, it should work correctly, provided there is data.

    You can go to the respective Invoice, click on the "Lines" - > "Item Receipt Lines", and check whether the Receipt Lines are displayed.

    Please share the code written on "Purch. Inv. Line" - "OnAfterGetRecord"

  • jsshivalik Profile Picture
    3,099 on at

    Hi

      When i display message then it displays value. Why on report it is not printed or i checked in dataset also it is blank.

    If i add variable in Header then it displays value found in Header . If i add variabe in Line then it displays value found in line. Whereas all other variables work in both condition.

    Thanks

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans