Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Set demand priority based on record producer values

SD29
Tera Expert

Hi All,

I have a Record Producer which creates a Demand.   The record producer has the Urgency and Impact values. When the record producer is submitted it creates a Demand where it create priority of the demand based on the Urgency & Impact values we select from the record producer. While the demand is getting created the priority is being calculated incorrect.

High/High is giving low priority. which is not correct.

FYI: 1) The priority is being calculated correctly when a demand is created manually but not from the Record producer.

              2) we don't have priority field on the record producer.

please help.

Thanks,

SD

1 ACCEPTED SOLUTION

You can use below script in the onBefore Insert business rule



current.priority = calculatePriority(current.impact, current.urgency);



Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

7 REPLIES 7

david_myers
Tera Contributor

How is the Priority calculated when creating it manually?   If it's not from a business rule I would guess there's some client script that is setting it based on the Impact/Urgency values.   in that case you may have to replicate it in the the Record Producer script to set current.priority.  


HI David,



Yes, we are using 2 onChange client scripts to calculate priority.


1) calculate priority onchange urgency


2) calculate priority onchange impact.


How can i use this script in RP?


Here is the script:



function onChange(control, oldValue, newValue, loading) {


      var values = new Array();


              values.push(g_form.getValue('impact') || 0);


              values.push(g_form.getValue('urgency') || 0);



      if (loading)


              return;


      var ga = new GlideAjax('ServiceAjax');


      ga.addParam('sysparm_name','calculatePriority');


      ga.addParam('sysparm_values', values);


      ga.getXML(calcReturn0,null,'priority');


}



Thanks,


SD


Manjeet Singh
ServiceNow Employee
ServiceNow Employee

Hi,



Looks at the example here done something similar for incident - Record Producer change Priority