web
You’re offline. This is a read only version of the page.
close
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

Read Only Section in dynamics 365

(0) ShareShare
ReportReport
Posted on by 1,085

Hello Community Experts,

I want to make a section read only in lead entity, how do i achieve that?

Kindly guide,

Best Regards,

Sumaira Noor

I have the same question (0)
  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    Hi,

    You need to make all the fields within the section in readOnly mode.

    You can use a business rule for this scenario  

    Maybe a JS code if the logic is more complex:

    formContext.getControl(arg).setDisabled(bool);

  • Verified answer
    LuHao Profile Picture
    40,892 on at

    Hi Sumaira,

    We can directly set the field as a read-only field in the form editor.

    Go to https://make.powerapps.com/, select the entity and edit the form.

    pastedimage1588753643986v3.png

    Click the field, check Read-only field. Do this for all fields in the section.

    pastedimage1588753732699v4.png

    Save and publish.

  • Sumaira Noor Profile Picture
    1,085 on at

    Thanks a lot for the response Mehdi and Lu

    Since the logic is complex I'm trying to lock or unlock the section

    I had earlier set the lock or unlock on form based on some condition, but there is another change they need, they do not want the entire form to be locked, they want specific tabs and sections to be locked/unlocked not all

    Is the only way left is to lock/unlock individual fields as mehdi specified in the code or specific section can also be locked and unlocked?

    Kindly Guide,

    Best Regards,

    Sumaira Noor

  • Verified answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    Hi, 

    Please refer to this sample code, I lock all the fields located in the company section located in Summary tab

    function disableSectionFields(executionContext) {
        var formContext = executionContext.getFormContext();
        var summaryObj = formContext.ui.tabs.get("Summary");
        var companyObj = summaryObj.sections.get("company");
        
        var companyObjFields = companyObj.controls.get(); 
    
        for (var i = 0; i < companyObjFields.length; i  ) {
            companyObjFields[i].setDisabled(true);
        }
    
    }

  • meelamri Profile Picture
    13,216 User Group Leader on at

    Hi,

    Any news about my last post ?

  • Sumaira Noor Profile Picture
    1,085 on at

    Thanks a lot for the help mehdi

    Many thanks

    This code worked

    Best Regards,

    Sumaira Noor

  • Suggested answer
    JasonSolvesIT Profile Picture
    on at
    I've confirmed that the verified answer (meelamri on 06 May 2020 at 13:36:56) confirmed works except there is a typo in the Javascript. There is no increment to the i variable in the loop. 
     
    It should read:
        for (var i = 0; i < companyObjFields.length; i++  ) {
            companyObjFields[i].setDisabled(true);
    After fixing this, I did the following to launch the fixed Javascript in the "On Load" event to automatically lock fields in a Section:
    1. Uploaded my version of the Javascript (with the bug fixed) as an application component
    2. Updated the form's "On Load" event
      1. Left Table Column Dependencies blank
      2. Set Handler to pull from the Library component where the Javascript function is stored
      3. Set the Function field to the function name (disableSectionFields if you use meelarmri's function)
      4. Turned on the Enabled checkbox
      5. Turned on the "Pass execution context as first parameter"
    I will be building on this logic to make any section conditionally Read Only using generic code that can be controlled using application logic.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 49 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans