Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Answered

on change of priority field in case entity

(0) ShareShare
ReportReport
Posted on by 524

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.

  • Suggested answer
    XM-22040801-0 Profile Picture
    XM-22040801-0 11 on at
    RE: on change of priority field in case entity

    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:

    pastedimage1681306899977v1.png

    For a Normal priority:

    pastedimage1681306940100v2.png

  • Verified answer
    Guido Preite Profile Picture
    Guido Preite 54,087 Super User 2024 Season 1 on at
    RE: on change of priority field in case entity

    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

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans