Onchange client script when Priority changes

Shankar Manohar
Mega Guru

Dear All,

  Greetings Everyone,

            I am testing something in my personal instance for self learning. I created a custom field like "reason". I have Priority values from 1-5.

        Now What my requirement is.. When ever the Priority changes from P4 or P5 to something else ( P1,or P2 or P3), My custom reason field should be visible and be made mandate. And when the severity changes from P4 to P5, nothing should happen.

      The reason because, I have a SLA set up for P1 to P3 tickets.. So when the ticket is upgrading from P4 to P3, the SLA is getting attached with the time already elapsed. So I want to enter the reason to review the ticket for upgrade..

I have my code working for all the priority changes but what I want is only for when the priority gets upgrade from either P4 of P5 to P1/P2 and P3..

  Any suggestions would be greatfu;

1 ACCEPTED SOLUTION

Try with this.



newValue != oldValue && ( (oldValue == P4 || oldValue == P5) && (newValue == P1 || newValue == P2 || newValue == P3))


View solution in original post

4 REPLIES 4

Community Alums
Not applicable

When you build an on-change client script you have a couple values available by default: oldValue and newValue



The oldValue contains, predictably, what the field was before it was changed. newValue contains the new value. You can build your logic around these.


Shankar Manohar
Mega Guru

Thanks for the suggestion Kevin,



I had the code figured out for newValue != oldValue and my setDisplay and mandate are working fine as expected.



However, I am stuck with the display and mandate should happen only if the priority is changed from P4/P5 to something else.. but not always.. Here in this If condition.. I need some assistance..



Thanks


Shan


Try with this.



newValue != oldValue && ( (oldValue == P4 || oldValue == P5) && (newValue == P1 || newValue == P2 || newValue == P3))


Thanks Deepak,



    That logic worked.



Thanks


Shan