Hide Formselector on the Form – Dynamics 365 CE/CRM

Hi Everyone,

Today I got a requirement to hide FormSelector on the Form as Users would have access to multiple forms but we have to navigate them to right form based on a field value on the record and we shouldn’t give an option to change the form to the User.

My initial thought was it’s not possible to hide formselector but one of my colleagues came up with the below piece of the code and it worked like a charm.

Logic is simple, set Visibility of the forms to False.

 var formContext = executionContext.getFormContext();
    formContext.ui.formSelector.items.get().forEach(function (item, index) {
        // hide all the form apart from Opportunity.
        if (item.getLabel() != "Opportunity") {
            item.setVisible(false);
        }
    });

Without above code, we see formselector

With code, we don’t see formselector

Hope this helps.


Happy 365’ing
Gopinath

One thought on “Hide Formselector on the Form – Dynamics 365 CE/CRM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s