Announcements
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.
Hi Ricardo, thanks. Will try to modify this code and make it work.
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.
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?
Well observed. Thanks for that!
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
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,
Thank you both. I am not great in JS - can you provide me a reference site. I'm in a middle of learning JS.
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,
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,807 Super User 2024 Season 2
Martin Dráb 229,135 Most Valuable Professional
nmaenpaa 101,156