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)

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,243 Super User 2025 Season 2 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

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