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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

how to retrieve a field with table relation

(0) ShareShare
ReportReport
Posted on by 5,136

Simple question I hope: I am trying to retrieve a value from Purch Inv. Header table.  This value field is Code data type and has a table relation with Payment code table.  Can you please advise how to retrieve this field (payment code)?  After I perform the necessary filter, in the findset section , this field is blank.  Please help.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Suresh Kulla Profile Picture
    50,269 Super User 2026 Season 1 on at

    Please paste your code so we can review and also you check if your field is a normal or flowfield, if it is a flowfield you have to use CALCFIEDLS.

  • mbr Profile Picture
    5,136 on at

    The Payment Code is a normal field.  but it has a table relation with Payment Code Table.

    Here's my code:

                       VLE.RESET;

                       VLE.SETRANGE("External Document No.",TransferLine."Transport Vendor Invoice No.");

                       VLE.SETRANGE(Open,FALSE);

                       IF VLE.FINDSET THEN

                         GetStatus := 'Paid'

                       ELSE

                         BEGIN

                           GetStatus := 'Not Paid';

                           VLE.SETRANGE(Open,TRUE);

                           IF VLE.FINDSET THEN

                             BEGIN

                                 VLE.CALCFIELDS(Amount);

                                 GetAmount :=  FORMAT(ABS(VLE.Amount),0,'<Precision,2><Standard Format,1>');

                                 //now, get the payment Terms Code

                                 PurchInvHdr.RESET;

                                 PurchInvHdr.SETCURRENTKEY("No.");

                                 PurchInvHdr.SETRANGE("No.",VLE."Document No.");

                                 IF PurchInvHdr.FINDSET THEN

                                   BEGIN

                                    MESSAGE('payment =%1 and no is %2',PurchInvHdr."Payment Method Code",PurchInvHdr."No.");

                                      GetTerms := PurchInvHdr."Payment Method Code";

                                   END;

                                 MESSAGE('Amount=%1 for extdoc no %2 and vle amount=%3, extdecno=%4,Open=%5 and terms=%6',GetAmount,TransferLine."Transport Vendor Invoice No.",ABS(VLE.Amount),VLE."External Document No.",VLE.Open,GetTerms);  //mbr test

                             END;

                         END;

    Note: The problem is in the PurchInvHdr."Payment Method Code".  It gives me blank.  I feel like I have to do something before I get the actual value?

  • Verified answer
    mbr Profile Picture
    5,136 on at

    Hi All, I don't know what I did but above code just started to work.  It's really strange.  I didn't do anything different.  I was racking my brains as to what to do when it's a normal field albeit with table relation.  Anyway, I am not getting the value for payment method code above.  Thank you anyway.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans