Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Answered

on change of priority field in case entity

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,063 Moderator 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

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans