Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Flowing the data from purch inv. line to purch. rcpt. line

(0) ShareShare
ReportReport
Posted on by 2

Hello All,

I have added two fields in purch. rcpt. line,purch inv. line,its header tables and other related tables.The added field values are inserted in the purchase order while invoicing only.So,I have to pass that value to their corresponding  purch. rcpt. line which has been already posted.I wrote the following code but cannot figure it out where to put it exactly.

PurchRcptLine.SETRANGE("Document No.","Document No.");
IF PurchRcptLine.FINDFIRST THEN BEGIN
   ItemLedgEntry.SETRANGE("Document No.",PurchRcptLine."Document No.");
   IF ItemLedgEntry.FINDFIRST THEN REPEAT
     IF ItemLedgEntry."Document Type" = ItemLedgEntry."Document Type"::"Purchase Receipt" THEN BEGIN
         ValueEntry.SETRANGE("Item Ledger Entry No.",ItemLedgEntry."Entry No.");
         IF ValueEntry.FINDFIRST THEN BEGIN
             IF ValueEntry."Document Type" = ValueEntry."Document Type"::"Purchase Invoice" THEN BEGIN
                 RcptLinePragyapan := ValueEntry.PragyapanPatra;
                 RcptLineLC := ValueEntry."Letter of Credit/Telex Trans.";
                 PurchRcptLine.SETRANGE("Document No.",ValueEntry."Document No.");
                 IF PurchRcptLine.FINDSET THEN REPEAT
                     PurchRcptLine.PragyapanPatra := RcptLinePragyapan;
                     PurchRcptLine."Letter of Credit/Telex Trans." := RcptLineLC;
                     PurchRcptLine.MODIFY;
                 UNTIL PurchRcptLine.NEXT = 0;
             END;
         END;
   END;
 UNTIL ItemLedgEntry.NEXT = 0;
END;

*This post is locked for comments

  • Suggested answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 on at
    RE: Flowing the data from purch inv. line to purch. rcpt. line

    Why not to create flowfield or lookup field in rcptline to display the field or If that data is just for reporting purpose then better to write program on onaftergetrecord of page and display the data using variables.

  • Sulav Thapaliya Profile Picture
    Sulav Thapaliya 2 on at
    RE: Flowing the data from purch inv. line to purch. rcpt. line

    The field I have added in all the related tables are "Pragyapanpatra" and "Letter of Credit".

    So,When client receive the goods,they are unknown about these values,so they just receive it.They will come to know these values when their physical invoice arrives to them.Now,when they invoice that released order,at that time they put their values and post it.After that,They will create a new order where they apply item charge.While getting the purchase receipt lines,their should be the value of pragyapanpatra and letter of credit from their corresponding invoice line.I have to do that modification.All the lines will have same pragyapan and letter of credit values for the individual header.I can get their values from value entries and assign it to those receipt lines.Only problem is where do I write the code.Hope you have understand the requirement.

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 44,626 on at
    RE: Flowing the data from purch inv. line to purch. rcpt. line

    Sulav,

    There are couple of things i want to ask, not sure why you looking at ledger entries to get values, as you mentioned in your post they will enter those values on the order before invoicing and then do invoicing those values will be transferred from order to Invoice.

    Regarding where to add your code, what do you want to do if there are multiple receipts for an order, do you want to update all the lines or only the last receipt ?

    In Codeunit 90 there is a function called InsertInvoiceOrCreditMemo, after the PurchInvLine.INSERT, Add the code to find all the Receipt Lines for that Order and Line No. and Update the field Values.

    Thanks

    Suresh

  • Suggested answer
    RockwithNav Profile Picture
    RockwithNav 6,562 on at
    RE: Flowing the data from purch inv. line to purch. rcpt. line

    Hi Sulav,

    As you said, While Invoicing you want some field to get that updated in Purchase Receipt.

    Why you want that field to get updated during Invoicing because Ideally it should get updated while receipt only. Now further to your question you said the reason behind this is you get that particular field while Invoicing only so here my question is why dint you get that field during receipt, it is something a loophole in the system or the customization is like this - Pardon me but I am really curious to know this. Now if you are getting that field while Invoicing why you want it to get that updated in Receipt?

    If you follow the standard rule and protocols then it's never recommended to update forcefully something on Receipt if you are doing an Invoicing. if you have followed the standard business logic then it was just a 2 minute job for you as you just need to simply put a field in Purchase Header and the same field with the same ID on Receipt and Invoice and you are done. If you get it populated during Order it should have automatically carry forwarded till Invoice posting.

    If its something that is supposed to be done only once and it's just a simple field to be updated then too you can go ahed and do but if you are planning it to be handled each and every time the user is doing an Invoice then I am quiet afraid of the code and the Process that you are trying to achieve.

  • Verified answer
    RE: Flowing the data from purch inv. line to purch. rcpt. line

    Hi,

    You can either put this code when it is Invoicing Only post, which you have to do changes in codeunit 90 and 91 as I explained on my previous replies.

    Or, you can put up an Action button on the Page Posted Purchase Receipt (136).

    Hope it helps.

  • Sulav Thapaliya Profile Picture
    Sulav Thapaliya 2 on at
    RE: Flowing the data from purch inv. line to purch. rcpt. line

    I am confused on where to put these code.So, that values will be flowed properly.I tried putting these codes in GetPurchRcptLines() function of purch inv line table.But its not working

  • Suggested answer
    RE: Flowing the data from purch inv. line to purch. rcpt. line

    Hi,

    Exactly. Codeunit 91, will check whether it is a GRN or Invoice or both. If you follow the trace, after creating the PurchRcptLine, in Codeunit 90, update your fields. Your code seems fine. What is the exact problem are you facing now?

  • Sulav Thapaliya Profile Picture
    Sulav Thapaliya 2 on at
    RE: Flowing the data from purch inv. line to purch. rcpt. line

    The process is something like this:

    Client will first receive the goods where they do not put the values of newly added fields.

    At the time of invoicing only  they insert the values of those newly added fields and post it.Now,I have to flow that value to their corresponding purch. rcpt. line after invoicing

  • Suggested answer
    RE: Flowing the data from purch inv. line to purch. rcpt. line

    Hi,

    If you are only calling this when the Invoicing only, then check Codeunit 91 Purch.-Post (Yes/No), function Code(). In there the logic behind Invoicing only is visible.

    In Codeunit 90 Purch.-Post, in OnRun() function, the PurchRcptLine is getting in line 806 (Or search with PurchRcptLine.INSERT; in the object).

    You can apply your code after this line of code.

    Please understand there can be other conflicts with Item Ledger Entries and Value Entries to be solved. Do test well.

    Hope it helps.

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