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

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Decode Option Field Value

(0) ShareShare
ReportReport
Posted on by 172

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

I have the same question (0)
  • Hannes Holst Profile Picture
    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?

  • MateuszKILINSKI Profile Picture
    172 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
    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
    172 on at
    RE: Decode Option Field Value

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

  • Verified answer
    Suresh Kulla Profile Picture
    50,237 Super User 2025 Season 2 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.

  • Verified answer
    MateuszKILINSKI Profile Picture
    172 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));


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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Alexander Ermakov Profile Picture

Alexander Ermakov 2

#2
SC666 Profile Picture

SC666 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans