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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Make form read only
Power Apps
Unanswered

Make form read only

(0) ShareShare
ReportReport
Posted on by 945

Hi guys,

 

For model-driven form, how to make the whole control read only or un-editable by certain condition ?

For example, in one of its field, I have Posted field. When Posted filled with Yes, all the controls in the form will be read only, cannot edit.

 

Thanks

I have the same question (0)
  • Verified answer
    cchannon Profile Picture
    4,702 Moderator on at

    You can accomplish this with business rules or with javascript.

     

    In business rules, you would set up your condition, then look through all the controls one at a time and set each to read only. This is an easy, no-code solution but any time you add more fields you will need to add them to the rule.

     

    In Javascript, you can retrieve the tabs and sections on the form, then for each section you can retrieve all controls. This makes for a pretty easy way to loop through all controls and set them Disabled one at a time without needing to explicitly name them all. So, while this approach does require code, it would self-scale and handle any fields being added or removed from the table/form without you needing to make updates.

  • Ram Prakash Duraisamy Profile Picture
    5,593 Super User 2025 Season 2 on at

    Hello @Axal,

     

    You can write JavaScript to disable all the fields

     

    function disableAllFields(executionContext) {
    var formContext = executionContext.getFormContext();
    if(formContext.getAttribute(FieldLogicalName).getValue()=YES){ formContext.ui.controls.forEach(function (control, i) {
     if (control && control.getDisabled && !control.getDisabled()) {
     control.setDisabled(true);
     }
     });
     }}

     Call the above function in OnLoad Operation

     

    Please find my video for step by step guidance for writing Javascript and Subscribe the channel for all Basics of Dataverse.

     

    https://www.youtube.com/watch?v=x8kYNCkikgs&t=7s

     

     

    Please mark as Answer if it is helpful and provide Kudos


    Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA
    Blog : https://microsoftcrmtechie.blogspot.com

  • Axal Profile Picture
    945 on at

    Hi both,

    Thanks. I using Business Rule.

    Many thanks for all advices. 😊

  • Pooja08 Profile Picture
    on at

    Hello @rampprakash,

     

    I have used subgrids in my form, i could see it is not disabling the subgrids. Can you please let me know how can i disable or lock the subgrids after form is saved or submitted?

  • Ram Prakash Duraisamy Profile Picture
    5,593 Super User 2025 Season 2 on at

    Hi @Pooja08 

     

    Unfortunately we cannot Lock Subgrid in OOB way, you need to use document.getElementById to do the same.


    let me know if you need more information

  • Roo88 Profile Picture
    18 on at

    Yes, I would like more information on locking subgrid fields.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard