web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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,023

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
    meelamri Profile Picture
    13,218 User Group Leader on at

    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,

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    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

  • Verified answer
    LeoAlt Profile Picture
    16,341 Moderator on at

    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

  • Suggested answer
    Vipin J Profile Picture
    1,603 on at

    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

  • Suggested answer
    Karrar Al-Rubayee Profile Picture
    10 on at

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

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 61 Super User 2026 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 38 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 24 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans