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 :
Finance | Project Operations, Human Resources, ...
Unanswered

How can I hide tabs based on selection of 2 fields?

(0) ShareShare
ReportReport
Posted on by 65

Hello,

I have a form and many tabs in it. In the general tab, I select primary asset type( reference group I mean lookup) and asset type(enum). I need to hide and display some of the tabs based on the selection of both primary asset types and asset types. I wrote a code for this (I use OnModified event to select Primary asset Type) and I can hide or display tabs based on the selection of primary asset type but I am not sure how do I add those code selections of asset types, too.

If someone can help me with this I would be really appreciated it.

[FormDataFieldEventHandler(formDataFieldStr(EntAssetObjectTable, FixedAsset, PrimaryAssetType), FormDataFieldEventType::Modified)]
    public static void PrimaryAssetType_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
    {
        FormDataSource dataSource = sender.datasource();
        EntAssetObjectTableFormDataFieldEvent::UpdateTab(dataSource);
    }

    /// 
    ///
    /// 
    /// 
    /// 
    [FormDataSourceEventHandler(formDataSourceStr(EntAssetObjectTable, FixedAsset), FormDataSourceEventType::Activated)]
    public static void FixedAsset_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
    {
        EntAssetObjectTableFormDataFieldEvent::UpdateTab(sender);
    }

    public static void UpdateTab(FormDataSource sender)
    {
        
        FixedAsset fixedAsset = sender.cursor();
        FormRun formRun = sender.formRun() as FormRun;


        FormControl le = formRun.design().controlName(formControlStr(EntAssetObjectTable, TabA));
        FormControl pg = formRun.design().controlName(formControlStr(EntAssetObjectTable, TabB));
        FormControl c = formRun.design().controlName(formControlStr(EntAssetObjectTable, TabC));
        FormControl d = formRun.design().controlName(formControlStr(EntAssetObjectTable, TabD));
        FormControl e = formRun.design().controlName(formControlStr(EntAssetObjectTable, TabE));

        a.visible(false);
        e.visible(false);
        c.visible(false);
        b.visible(false);
        e.visible(false);

        var primary = PrimaryAssetType_WM::findByRecId(fixedAsset.PrimaryAssetType);
        var type = FixedNonFixedSelectionBaseEnum_WM::NonFixedAssets;
            switch(primary.Code)
            {
                case 'x':
                    a.visible(true);
                    break;

                case 'y':
                    b.visible(true);
                    break;

                case 'z':
                    c.visible(true);
                    d.visible(true);
                    break;

                case 't':
                    e.visible(true);
                    a.visible(true);
                    break;

            }

Thanks, regards...

I have the same question (0)
  • ergun sahin Profile Picture
    8,824 Moderator on at
    RE: How can I hide tabs based on selection of 2 fields?

    I did not fully understand the problem. Let's talk about single-field control first;

    I see that you use both OnActivated and OnModified in the code. Actually you have to write in OnActivated, not OnModified. Why did you use OnModified? OnActivated wasn't enough?

    If we talk for two fields, instead of filling the enable value as true/false directly, you should keep it in a boolean variable.

    You may then concatenate with the value from the enum

    Or you can create branchs with enum as a second condition inside the switch case.

    Since we do not know the relationship between the two data, it is difficult to say for sure. If you show your expectations with examples, we can help you combine the two terms.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 650 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 582 Most Valuable Professional

#3
CU05031448-0 Profile Picture

CU05031448-0 526

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans