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 :
Customer experience | Sales, Customer Insights,...
Answered

Disable all fields under every section on a specific tab

(1) ShareShare
ReportReport
Posted on by 20

I am converting old XRM code to work on UI and I can't seem to get the loops nested right.  Rather than just looping through controls and hard coding the section name "PERSONALINFORMATION" name, how can I just give the tab name "ContractTerms" then automatically loop through all sections and controls under that tab?

Here is what I have:

function OnLoad(executionContext)
{

let formContext = executionContext.getFormContext(); 


formContext.ui.tabs.get('ContractTerms')
.sections.get('PERSONALINFORMATION')
.controls.forEach((e) => e.setDisabled(true));
 

}

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Disable all fields under every section on a specific tab

    Hello,

    Check the following:

    function OnLoad(executionContext) {
    	let formContext = executionContext.getFormContext(); 
    	formContext.ui.tabs.get('ContractTerms')
    	.sections.forEach(function(section) {
    		section.control.forEach(function(control) {
    			control.setDisabled && control.setDisabled(true);
    		});
    	});
    }

  • richardpanek Profile Picture
    20 on at
    RE: Disable all fields under every section on a specific tab

    Unfortunately this doesn't seem to work, no error however it doesn't disable any of the fields like the original code posted does.

  • Suggested answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at
    RE: Disable all fields under every section on a specific tab

    Hi richardpanek,

    Please debug your code.

    If I answer your question then please mark it as verified.

    Let me know if I can provide you with more details.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform & Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Disable all fields under every section on a specific tab

    Ok. I mistyped. Should be controls, not control:

    function OnLoad(executionContext) {
    	let formContext = executionContext.getFormContext(); 
    	formContext.ui.tabs.get('ContractTerms')
    	.sections.forEach(function(section) {
    		section.controls.forEach(function(control) {
    			control.setDisabled && control.setDisabled(true);
    		});
    	});
    }

  • richardpanek Profile Picture
    20 on at
    RE: Disable all fields under every section on a specific tab

    Still doesn't appear to work, does it for you?

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Disable all fields under every section on a specific tab

    Works for me.

  • richardpanek Profile Picture
    20 on at
    RE: Disable all fields under every section on a specific tab

    Awesome, thanks for the help

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 122 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 101

#3
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 62

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans