Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Iterate possible values of a Option Field in C/AL

Posted on by 175

Hi, I want to do a function that returns the possible values of an OptionField in Text (By comma separated values) 

I have tried this but it loops and never exit.... Any Idea?

4201.a.png

Calidad -> Is the Option Field that has several possible values

Thank you...

*This post is locked for comments

  • Verified answer
    aavio Profile Picture
    aavio 895 on at
    RE: Iterate possible values of a Option Field in C/AL

    another solution may be-->

    there is a virtual table, Field (2000000041). In new version from 2013R2 they have the Optionstring field in the table.

  • Jaime Figueras Profile Picture
    Jaime Figueras 175 on at
    RE: Iterate possible values of a Option Field in C/AL

    Works perfectly (Thanks to everyone)

  • Binesh Profile Picture
    Binesh 7,885 on at
    RE: Iterate possible values of a Option Field in C/AL

    Hello, Agree with [tag:Suresh]

    RecRef.GETTABLE(Rec);

    FieldRef_G := RecRef.FIELD(39); // Replace with your Calidad Field No

    OptionStr := FORMAT(FieldRef_G.OPTIONCAPTION);

    if you need semicolon instead of comma then use

    OptionStr := CONVERTSTR(OptionStr,',',';');

  • Verified answer
    TharangaC Profile Picture
    TharangaC 23,116 on at
    RE: Iterate possible values of a Option Field in C/AL

    Agreed with Suresh. You can use the OPTIONCAPTION to get the caption values.

    Check the link :msdn.microsoft.com/.../dd338979.aspx;MSPPError=-2147217396

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Iterate possible values of a Option Field in C/AL

    Just use FieldRef to get the optionCaption, Create RecRef for the record and then assign RecRef

    RecRef.GETTABLE(Rec);

    FieldRef := RecRef.FIELD(25); // Replace with your Calidad Field No

    OptionStr := FORMAT(FieldRef.OPTIONCAPTION);

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans