Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

hiding section on the form

(0) ShareShare
ReportReport
Posted on by 1,019

Hi,

I would like to hide the section on the form. my tab name is Address and section name is tab2_section 2. 

could you please help me by providing the exact code on how it would look after using below code  or anyother code as I am not familiar with js code.

below is the sample code I found online to hide the sectiom

function HideShowSection(formContext, section, tab, bool) {
try {
formContext.ui.tabs.get(tab).sections.get(section).setVisible(bool);
}
catch (e) {
Alert(e.message + " - " + section);
}
}

  • Suggested answer
    Karrar Al-Rubayee Profile Picture
    10 on at
    RE: hiding section on the form

    Hi James, you might find this handy using business rules instead https://youtu.be/-X-3cXDBbzI

  • Suggested answer
    Vipin J Profile Picture
    1,583 on at
    RE: hiding section on the form

    I have created some Generic Method to Hide and Show Tab and Section

    Please refer here : https://vjcity.blogspot.com/2021/07/generic-method-to-hide-and-show-tab-and.html

  • Verified answer
    LeoAlt Profile Picture
    16,331 Moderator on at
    RE: hiding section on the form

    Hi partner,

    For example, if you want to hide the Tab "Address", you could use the following code.

    function showTab(executionContext){
        var formContext=executionContext.getFormContext();
        formContext.ui.tabs.get("Address ").setVisible(true);//show the Address tab, and false means hide the tab at the same time
    }

    If you want  to hide the section "tab2_section2", use the following code.

    function showSection(executionContext){
        var formContext=executionContext.getFormContext();
        formContext.ui.tabs.get("Address ").sections.get(section).setVisible(true);
    }

    Pay attention that since we are using "exectionContext" as parameter in form event, we should click the "Pass execution context as first parameter" when we add the events.

    2870.pastedimage1580712989839v1.png

    You could also refer this doc for more information.

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/formcontext-ui-tabs

    Best Regards,

    Leo

  • Verified answer
    gdas Profile Picture
    50,089 Moderator on at
    RE: hiding section on the form

    Hi,

    If you are looking for JS code solution then try with below code.

        function HideSection(executionContext) {
            var formContext = executionContext.getFormContext();
            try {
                formContext.ui.tabs.get("Address").sections.get("tab2_section2").setVisible(false);
            }
            catch (e) {
                Alert(e.message   " - "   section);
            }
        }

    Please validate the section/Tab name again , its should be without space and in the event handler pass the executioncontext and put function name.

    https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/clientapi-execution-context

  • Suggested answer
    meelamri Profile Picture
    13,212 User Group Leader on at
    RE: hiding section on the form

    Hello,

    You can hide a section in the form designer without using JavaScript. Please give your scenario to find out if you really need a JavaScript.

    Mehdi,

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,000 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans