Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

2 set of dropdowns on a field based on value selected in another field

(0) ShareShare
ReportReport
Posted on by 210

I want that If i select cashInflow ,3 Options in form of dropdown should come from a whole set of Enum should appear in another field and if i select outflow another 3 should Appear from same set.how can i achieve this.

field(2; "Level-01_Descrption"; Enum CashflowLevel1Description)

       {

           Editable = false;

           trigger OnValidate()

           var

               OptionsVar: Enum CashflowLevel1Description;

           begin

               OptionsVar := "Level-01_Descrption";

               case OptionsVar OF

                   OptionsVar::"Cash Inflow":

                   begin

                   "Level-02_Descrption":= "Level-02_Descrption":: ???????????????

                   end;

                   OptionsVar::"Cash Outflow":

                   begin

                   "Level-02_Descrption":= "Level-02_Descrption":: ????????????

                   end;

               end;

           end;

       }

       field(3; "Level-02_Code"; Enum CashFlowLevel2Code)

       {

       }

       field(4; "Level-02_Descrption"; Enum CashflowLevel2Description)

       {

       }

  • Pragya752 Profile Picture
    Pragya752 210 on at
    RE: 2 set of dropdowns on a field based on value selected in another field

    Hi i dont think u r getting my question.I dont want to assign a value to reclevel2description i want to assign a set of options for user to select if cash inflow is in Reclevel1Description and vice versa for Cash Outflow.That is why i was talking about iterating enum.For ex: if u have state field and district field,and if u select punjab than different dropdown options shd come for district than if u select gujrat in state.

  • Suggested answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: 2 set of dropdowns on a field based on value selected in another field

    Yes, you can do if else condition on an OptionField..

    variableOptions: Option "Vendor","Another Vendor";
    if (YourFiled = variableOptions::"Default (Vendor)") then begin
                    Do Something

    As you said your enum is the same for both fields, so you can set a specific value for your enum based on the value selected in the first field..

                            if (Rec.Level_01_Descrption = Rec.Level_01_Descrption::"Cash Inflow") then begin
                                begin
                                    Rec.Level_02_Descrption := Rec.Level_01_Descrption::"Field4_CashInflow";
                                end;
                            end
                            else
                                if (Rec.Level_01_Descrption = Rec.Level_01_Descrption::"Cash Outflow") then begin
                                    Rec.Level_02_Descrption := Rec.Level_01_Descrption::"Field7_CashOutflow";
                                end;

    However, I don't undertsand what you mean by "iterate the enum value from 0 to 5 if you select the cashInflow in your first field.. and 6,7 for cashOutflow..

    Regards

  • Pragya752 Profile Picture
    Pragya752 210 on at
    RE: 2 set of dropdowns on a field based on value selected in another field

    No, I have same Enum for both , I was thinking about iterating the enum for value 0 to 5 in case of cash inflow and value 6 and 7 as dropdown in cashOutflow option case.Can we do If else Condition On OptionMembers

  • Suggested answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: 2 set of dropdowns on a field based on value selected in another field

    Can you tell me if the CashflowLevel1Description and CashflowLevel2Description enums both are the same or different.. also if you want to set the specific value for the field 'Level-02_Descrption' based on the value you select on your first field?

    Here's how can you try it..

                        trigger OnValidate()
                        var
                            OptionsVar: Enum TestEnum;
                            Level: Enum TestEnum2;
                        begin
                            case Level_01_Descrption OF
                                Level_01_Descrption::"Cash Inflow":
                                    begin
                                        Level_02_Descrption := Level_02_Descrption::"Level_02_Descrption_CashInflow";
                                    end;
                                Level_01_Descrption::"Cash Outflow":
                                    begin
                                        Level_02_Descrption := Level_02_Descrption::"Level_02_Descrption_CashOutflow";
                                    end;
                            end;
                        end;

    Hope it helps you

    Regards

  • Suggested answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: 2 set of dropdowns on a field based on value selected in another field

    Hi Pragya752,

    If I understand correctly, you want to set different enums in other fields based on the option selected in your first field. For example, if 'cashinflow' is selected in your first enum field, then you want to set a specific enum with three options in your second field. If 'cashoutflow' is selected, then another set of three option fields should be set in the second field. If this is the case, then your code is not correct and I also recommend you do it on the page level and using a variable as the field on the page.. and set the value on the variable based on the validation field in your code..

    Please let me know if you need any help..

    Regards

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans