Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV forum
Answered

getting value from another table, based on value

Posted on by Microsoft Employee

on item no validate in courier table, im having this below code and works fine


IF item.GET("item No") THEN
DealerPrice:=item.DealerPrice;
VATIdent:=item."VAT Prod. Posting Group";

VATident value here is VAT14.5

how to map the VATident = VAT Posting Setup.VAT Prod. Posting Group

and get the value of the VAT % and store this value in courier.VAT% field..

any ideas.. thanks






Categories:
  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 58,864 Super User 2024 Season 2 on at
    RE: getting value from another table, based on value

    and what if you have multiple lines for VATIdent?

    do you always need first record VAT% only?

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: getting value from another table, based on value

    IF item.GET("item No") THEN  BEGIN

    DealerPrice:=item.DealerPrice;

    VATIdent:=item."VAT Prod. Posting Group";

    END;

    VATPosting.RESET;

    VATPosting.SETCURRENTKEY("VAT Prod. Posting Group");

    VATPosting.SETRANGE("VAT Prod. Posting Group",VATIdent);

    IF VATPosting.FINDFIRST THEN    BEGIN

     VATPer:= VATPosting."VAT %"

    END

    and it worked.. thanks for your support....

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 58,864 Super User 2024 Season 2 on at
    RE: getting value from another table, based on value

    1. if you multiple lines below IF THEN. Please use begin and end

    IF item.GET("item No") THEN BEGIN

     DealerPrice:=item.DealerPrice;

     VATIdent:=item."VAT Prod. Posting Group";

    END;

    2. You have written code in VATIdent onvalidate trigger.

    so you have to validate the field in 1st code.

    VALIDATE(VATIdent,item."VAT Prod. Posting Group");

    3. In order to use GET on VATPosting setup, you need to know all primary keys

    Primary key of Vat Posting setup table is VAT Bus. Posting Group,VAT Prod. Posting Group

    so you need VAT Bus. Posting Group

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: getting value from another table, based on value

    yes sure, thanks im trying this on, and im sure this wrong..

    VATIdent - OnValidate()

    //IF VATPosting.GET("VATIdent") THEN ( i dont know, how to search a field in the  .VAT Prod. Posting Group)

    //"VAT%":=VATPosting."VAT %";

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 58,864 Super User 2024 Season 2 on at
    RE: getting value from another table, based on value

    Please try yourself and let us know if you have any issues.

    please don't ask forum to do your job.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,349 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,212 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans