Setting a choice list from a calculated field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2019 04:20 AM
Afternoon all,
My brain hurts and I've looked at too many forum posts and am now very confused....
What I want to do is...
I have a drop down choice list (called u_work_load) with various options, name:"V.Low" Value:1, Med (2) ,High (3) , v.High (4) etc.
I also have a calculated field called "Total time taken" , u_total_time_taken
I want the drop down to change depending on the total time taken.
If the Total time taken is less than 30 , then u_work_load = 1 (so displays V.Low)
if total time taken is between 31 and 150 then u_work_load = 2
if total time taken is between 150 and 300 then u_work_load = 3 etc.etc.
I'm open to suggestions as to whether this is a business rule, or client script or even a calculated field. The drop down choice list can just be a string if it's easier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2019 04:28 AM
Hi Andrew,
better to do this in business rule which is server side code;
before insert/update business rule condition as when total time taken value changes
what type of field is that total time taken? is it a duration field? if yes then use below in BR script
var duration = current.u_my_duration.getGlideObject().getNumericValue();
var mins = (duration/1000/60);
if(mins < 30){
current.u_work_load = 1;
}
else if(mins > 30 && mins <= 150){
current.u_work_load = 2;
}
else if(mins > 150 && mins < 300){
current.u_work_load = 3;
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2019 08:26 AM
Hi Ankur,
The time taken field is just a floating point number field that calculates it's value by adding up various other fields.