Announcements
Hi,
In the case entity having the priority field, which is an option set, having options Low, Medium, High.
While updating the priority field, I need to restrict the user to degrade the values.
i.e, If a case record is created with priority as "Medium", then while updating this record, this field value should not be "Low", but it can be change to "High".
How we can achieve this functionality.
Hello,
Via javascript code, you can remove the choices you want from the priority field.
To remove an option, use removeOption(). See https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/controls/removeoption
For your needs, this would look like:
function onFormLoad(execCtx) { const formCtx = execCtx.getFormContext(); const priorityAttr = formCtx.getAttribute("prioritycode"); const priorityValue = priorityAttr.getValue(); if (priorityValue != null) { // Remove options const options = priorityAttr.getOptions(); const lowerPriorityOptions = options.filter(o => o.value > priorityValue); const priorityCtrl = formCtx.getControl>("prioritycode"); lowerPriorityOptions.forEach(o => priorityCtrl.removeOption(o.value)); } }
Register this function on form load.
Examples:
For a Low priority:
For a Normal priority:
this functionality can be done with javascript but I suggest to do a server-side check, using a synchronous classic workflow.
Probably with the classic workflow you can do it with just a couple of IF conditions (if you have only 3 values) otherwise also with a plugin (by writing c# code).
This to just give an overview, depends on the check you want to go forward me or other users can provide some links on how to implement it
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156