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...
Suggested Answer

Read Only Form Once Approved

(0) ShareShare
ReportReport
Posted on by 50

Hello All, 

How can I lock the entire form  "read only" when the approval box is checked off. I tried using business rules but I have to do one field at a time. I have over 30 fields on this form. 

I have the same question (0)
  • Suggested answer
    Henry J. Profile Picture
    5,237 on at

    Hello Emanuel,

    This could be done in JavaScript with formContext.data.entity to retrieve the list of attributes and setDisabled.

    Another way to approach this to set the record status as inactive once your process is done.
    That way, the record becomes read-only in the user interface.

    Henry

  • Ricardo Gimenez Profile Picture
    on at

    Hi Emanuel,

    As quoted by Henry, a JavaScript custom code would be the best approach here. As you said, Business Rule only allowed this action configuring one attribute at the time.

    Thanks,

  • Manny Floyd Profile Picture
    50 on at

    Thank you both. I am not great in JS - can you provide me a reference site. I'm in a middle of learning JS.

  • Suggested answer
    Ricardo Gimenez Profile Picture
    on at

    Hi Emanuel,

    Here is a good sample to inspire you build your solution:

    ==============================================================

    function MakeAttributesReadOnlyExceptOne(){

    Xrm.Page.data.entity.attributes.forEach(

    function (attribute, index) {

    var attributeName = attribute.getName();

    if (attributeName == "FieldLogicalName"){ //The field which you do not need to make read only

    Xrm.Page.getControl(attributeName).setDisabled(false);

    }

    else{

    Xrm.Page.getControl(attributeName).setDisabled(true);

    }

    });

    }

    ==============================================================

    Thanks,

  • Henry J. Profile Picture
    5,237 on at

    One small comment: Xrm.Page still works but is deprecated, so I would advise to use ExecutionContext.getFormContext instead.
    You can find guidance on this here:
    https://docs.microsoft.com/en-us/power-platform/important-changes-coming#some-client-apis-are-deprecated 

  • Ricardo Gimenez Profile Picture
    on at

    Well observed. Thanks for that!

  • Community Member Profile Picture
    on at

    Hi Emanual

    I had a similar requirement for a customer and this can be done via a simple JavaScript function which I am willing to share with you or you can use a simple workflow to make the record inactive which in turn will make the record read-only. My question here is, does the record have to be active and fields read-only, or can the entire record be deactivated?

  • Manny Floyd Profile Picture
    50 on at

    Hi Tyler,

    I am actually using Inactive and Active feature. So to answer your question, yes, the record can be approved and inactive. If the record is approved, all fields needs to be locked.

    I will truly appreciate your help. Dead line is approaching soon.

  • Manny Floyd Profile Picture
    50 on at

    Hi Ricardo, thanks. Will try to modify this code and make it work.

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 62 Most Valuable Professional

#2
#ManoVerse Profile Picture

#ManoVerse 57

#3
Pallavi Phade Profile Picture

Pallavi Phade 49

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans