- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 07:35 AM - edited 07-08-2025 07:51 AM
Suppose there is a variable in a record producer, and it's a choice field.
4 choices are there: A,BCD
If I choose A, the priority should be changed to critical 1.
How to do this? Trying to do using BR but can't query the condition where I can get variable type.
IN Record Producer script I already written one script for different condition
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 07:42 AM
Hi @Apaul ,
To achieve this behavior in ServiceNow, where selecting a specific value (like "A") in a choice variable on a record producer sets the priority to "Critical", you should use a Record Producer Script instead of a Business Rule.
Try this in your record producer script:
// Get the value of the variable from the record producer
var selectedChoice = producer.choice_variable; // Replace 'choice_variable' with your actual variable name
// Check if the selected value is 'A'
if (selectedChoice == 'A') {
current.priority = 1; // Set priority to Critical (1)
} // likewise do for all choices
- Business Rules run on the server side, and they don’t have direct access to variables on a record producer form.
- producer refers to the record producer variables.
- current refers to the record being created (e.g., an Incident or Request)
Mark this as helpful and correct, if this helpful.
Thanks,
Yaswanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 08:26 AM - edited 07-08-2025 08:35 AM
@Apaul @J Siva @Muhammad Salar @YaswanthKurre @Chaitanya ILCR
eeeey I just realised what we all are missing!!!
The Priority is calculated based on values in Urgency and Impact, so you cannot just set Priority to some value by a script, it shall be updating the two fields instead. ‼️
So the correct answer is as following:
if (your_variable == 'A'){
current.urgency = 1;
current.impact = 1;
//Priority will be caluclated: 1
}
if (your_variable == 'B'){
current.urgency = 2;
current.impact = 1;
//Priority will be caluclated: 2
}
if (your_variable == 'C'){
current.urgency = 2;
current.impact = 2;
//Priority will be caluclated: 3
}
if (your_variable == 'D'){
current.urgency = 3;
//Priority will be caluclated: 4
current.impact = 2;
}
What you have to decide is for B and D whether you want to have
- Urg 2 / Imp 1
- Urg 1 / Imp 2
- both calculates the Priority as 2
Eventually:
- Urg 3 / Imp 2
- Urg 2 / Imp 3
- both calculates the Priority as 4
Please test this solution and let me know how does this go.
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 07:56 AM
Hi @Apaul,
On the Record producer you can map the variable to the field (Priority) and for the variable you can make the ABCD as labels, and its valeus to be the same as for Priority.
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 08:04 AM - edited 07-08-2025 08:36 AM
❌EDIT: this method is not applicable for Priority
Priority is calculated based on values in Urgency and Impact. ❌
on the variable check on "Map to field" and map it to "Priority", then adjust the variable choices as following:
A - 1
B - 2
C - 3
D - 4
On the Portal the variable will display ABCD, in the backend the Priority will be displayed accordingly because the 1234 are mapped to 1234 with corresponding labels.
This will solve your issue with minimal efforts :))
❌EDIT: this method is not applicable for Priority
Priority is calculated based on values in Urgency and Impact. ❌
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 08:26 AM - edited 07-08-2025 08:35 AM
@Apaul @J Siva @Muhammad Salar @YaswanthKurre @Chaitanya ILCR
eeeey I just realised what we all are missing!!!
The Priority is calculated based on values in Urgency and Impact, so you cannot just set Priority to some value by a script, it shall be updating the two fields instead. ‼️
So the correct answer is as following:
if (your_variable == 'A'){
current.urgency = 1;
current.impact = 1;
//Priority will be caluclated: 1
}
if (your_variable == 'B'){
current.urgency = 2;
current.impact = 1;
//Priority will be caluclated: 2
}
if (your_variable == 'C'){
current.urgency = 2;
current.impact = 2;
//Priority will be caluclated: 3
}
if (your_variable == 'D'){
current.urgency = 3;
//Priority will be caluclated: 4
current.impact = 2;
}
What you have to decide is for B and D whether you want to have
- Urg 2 / Imp 1
- Urg 1 / Imp 2
- both calculates the Priority as 2
Eventually:
- Urg 3 / Imp 2
- Urg 2 / Imp 3
- both calculates the Priority as 4
Please test this solution and let me know how does this go.
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 08:37 AM
@GlideFather Ahh..
Yep it's a blunder.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 08:43 AM
ServiceNow fundamentals 101 😂 this is like always when I tried updating the Priority in a list view and Urgency and Priority are not displayed in that list...
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */