Hey guys so anyone know a good java script to lock and unlock all the fields on a stage based on owner and active stage
Thanks
Hey guys so anyone know a good java script to lock and unlock all the fields on a stage based on owner and active stage
Thanks
Hi ,
Try with this -
function processflow() { Xrm.Page.data.process.addOnStageChange(setReadOnlyFields); } function setReadOnlyFields() { // You can also check with selected stage name // var SelectedStageName = Xrm.Page.data.process.getSelectedStage().getName().toString().toLowerCase(); var activeStage = Xrm.Page.data.process.getActiveStage().toLowerCase(); var name = activeStage.getName(); if (name == "pending review") { // lock BPF field var field1 = Xrm.Page.getControl("header_process_fieldname"); if (field1!= null) { field1.setDisabled(true); } // lock form field Xrm.Page.getAttribute("fieldname").setDisabled(true); } }
Hi msboy,
1.You need to add the business rule in the main form entity.
2.Could you share your code so that we could do test or debug for you.
Best Regards,
Leo
Business Rule should be on your main entity, you do not have to create that on BPF entity. The fields that you want to lock and unlock are on the main entity.
Please see below as to how you can createt he Business Rule to lock and unlock
You need to rules, one to check Stage and other is to check the owner
To check the BPF stage via the category field,
And to check the Owner
Both of these rules are for the main condition, the Text view should look like the following
Hi,
you also need to do the checking during form onload.
hey so I tried to use bussines rule to lock fields, but its not working
and should the bussines rule be in the bpf entity or the main form enity
also I used a similar javascript, but when the user refresh the page the fields just unlocks
Hi partner,
1.You could use js to lock entire form.
function ReadOnly () { var controls = Xrm.Page.ui.controls.get(); for (var i in controls) { var control = controls[i]; if (!control.getDisabled()) { control.setDisabled(true); } } }
2.Since you said that you want to do this action based on owner or stage, I think using Business Roles is the best way for you.
Here is a blog for you to refer to.
Hope it helps,
Best Regards,
Leo
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... 291,269 Super User 2024 Season 2
Martin Dráb 230,198 Most Valuable Professional
nmaenpaa 101,156