Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

AL Code

Posted on by Microsoft Employee

How To define Option string  Value of Option type field While creating New Table in Visual Studio Code using AL .

E.g Field Name "Type "     Has Various Options "Placement,Sale, Purchase"

able 50100 Rldata
{
DataClassification = ToBeClassified;
fields
{
field(1;RLNO; code[20] )
{
DataClassification = ToBeClassified;
}
field(2;Type;Option

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: AL Code

    Thanks

  • Suggested answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 on at
    RE: AL Code

    You Can define as below the field with option data type

    field(1;type;Option)

           {

               OptionMembers=Quote,Order,Invoice,"Credit Memo","Payment Terms","General Journal","Sales Journal","Purchase Journal","Blanket Order";

               OptionCaption='Quote,Order,Invoice,"Credit Memo","Payment Terms","General Journal","Sales Journal","Purchase Journal","Blanket Order"';

               DataClassification = ToBeClassified;

           }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: AL Code

    Thanks For Response

    I need syntax to define Option Field   in table not for Option Parameter

  • Suggested answer
    GreatScott001 Profile Picture
    GreatScott001 115 on at
    RE: AL Code

    Option declaration like this:

    codeunit 50101 TestCodeunit
    {
        procedure HelloWithOptions(OptionParameter : Option A, B)
        var OptionVariable : Option C, "or D";
        begin
        end;
    }
    

    With help from people at the Microsoft/AL GitHub (https://github.com/Microsoft/AL/issues/2112).

    This add-in for VS Code has been a big help too, https://github.com/CloudReadySoftware/crs-al-language-extension

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans