Hi All,
I am trying to lock fields when the NEXT button in a BPF is clicked, I have used the code below, but i found out it only works when you refresh the form. I tried using the code in an onsave event, but i get the pop up that the form isnt saved and even when i click okay, it clears out the form and when i put the code inside the addOnStageChange event of the BPF, he form gets into a loop. Someone help me out, as this looks petty but yet wouldnt work-
function Lockfields(executionContext) {
var formContext = executionContext.getFormContext();
var appRequest = formContext.getAttribute("approval");
if (appRequest != null) {
if (appRequest.getText() == "draw") {
//lock fields
formContext.getControl("field").setDisabled(true);
formContext.getControl("field").setDisabled(true);
formContext.getControl("field").setDisabled(true);
Xrm.Page.data.save().then(Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId()));
}
}
}
In Between: How do i paste codes on here, since the change of the UI, i cant paste in a code editor?
*This post is locked for comments
Hi,
I'm assuming you have approval field on certain bpf stage and you want to lock other fields. Based on value in approval field.
Create one onload function.and add stage change event.
Then add your function in "formContext.data.process.addOnStageChange(LockFields)".
And remove "Xrm.Page.data.save().then(Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId()));".
Replace "appRequest.getText() == "draw"" with "appRequest.getText() === "draw"".
You might also want to do same on stage selection i.e.
formContext.data.process.addOnStageSelected(LockFields);
Regards,
Ketan
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,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156