Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Decode Option Field Value

Posted on by 170

Hello. I have a small issue, again ;)

As we know, in the option field proporties we can assign two proporties: Option String and Option Caption. In my case, I am trying to decode Option Caption to Option String for Payment Terms in CRM and NAV Integration. My properties:

OptionString: 7D,14D,30D,60D,90D

OptionCaption: 7 Days,14 Days,30 Days,60 Days, 90 Days (and OptionCaptionML simmilar for specific language).

Now, in Dynamics CRM Sales Order Page there is pretty value for Payment Terms, getted from OPTION CAPTION (f.ex. 60 Days). When I am tryign to validate field while creating Sales Order in NAV using:

SalesHeader.VALIDATE("Payment Terms Code", FORMAT(CRMSalesorder.PaymentTermsCode));

there is an error that there is no payment definition (60 Days) in Payment Terms table. And is is true. There is no 60 Days code, but 60D. 

It is possible to... decode (?) OptionCaption 60 Days to OptionString 60D ? 

*This post is locked for comments

  • Verified answer
    MateuszKILINSKI Profile Picture
    MateuszKILINSKI 170 on at
    RE: Decode Option Field Value

    That was a point :)

    LOCAL GetOptionValue(Table : Integer;Field : Integer;Value : Integer) : Text
    RecordRef.OPEN(Table);
    FieldRef := RecordRef.FIELD(Field);
    TempString := FieldRef.OPTIONSTRING;
    RecordRef.CLOSE;
    EXIT(SELECTSTR(Value+1,TempString));

    and then

    EVALUATE(OptVal, FORMAT(CRMSalesorder.PaymentTermsCode,0,9));
    SalesHeader.VALIDATE("Payment Terms Code", GetOptionValue(DATABASE::"CRM Salesorder",28,OptVal));


  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Decode Option Field Value

    Check Codeunit 5302 Outlook Synch. Type Conv, it has some functions for you to convert OptionToText and Vice Versa.

  • MateuszKILINSKI Profile Picture
    MateuszKILINSKI 170 on at
    RE: Decode Option Field Value

    This is bad idea :( What if the caption is in multilingual ?

  • Hannes Holst Profile Picture
    Hannes Holst 5,767 on at
    RE: Decode Option Field Value

    In this situation you'll need a data mapping.

    CASE FORMAT(CRMSalesorder.PaymentTermsCode) OF
      '60 Days': SalesHeader.VALIDATE("Payment Terms Code", '60D');
      '30 Days': SalesHeader.VALIDATE("Payment Terms Code", '30D');
    ...
    END;


    You can handle this through code, or a new field/table to lookup the NAV-value using the CRM-value.

  • MateuszKILINSKI Profile Picture
    MateuszKILINSKI 170 on at
    RE: Decode Option Field Value

    Yes, it is this field - the Code field and I need to decode from option caption using option string (where is the payment definition) to payment code

  • Hannes Holst Profile Picture
    Hannes Holst 5,767 on at
    RE: Decode Option Field Value

    Hi,

    The field "Code" of the table Payment Terms is a Code10-field and not an Option-field.

    Do you mean this field or a new field you've created?

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,928 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans