Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

how to retrieve a field with table relation

Posted on by 5,124

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

  • Verified answer
    mbr Profile Picture
    mbr 5,124 on at
    RE: how to retrieve a field with table relation

    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.

  • mbr Profile Picture
    mbr 5,124 on at
    RE: how to retrieve a field with table relation

    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?

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: how to retrieve a field with table relation

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans