- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2020 07:10 AM
Hi All,
Kindly help me . I got one requirement if the current choices start with pending then it changes to another state Work in progress
the script:
(function executeRule(current, previous /*null when async*/) {
var state = current.state.getDisplayValue();
gs.log("track4" + state);
//var a=current.u_email_update.getDisplayValue();
if((state == "Pending-Client") || (state== "Pending-Vendor") || (state == "Pending-Internal")){
//current.state = "Work in progress";
// current.state = 2;
current.state.setDisplayValue('Work in progress');
//current.stage == "closed_skipped";
//current.state = 3;
current.update();
}
})(current, previous);
my query how to set the current state setDisplayValue to Work in progress (I have used------ current.state.setDisplayValue('Work in progress')----these line-) but working not for state choice field kindly suggest . I have to set display WIP or not WIP's value(2).
Solved! Go to Solution.
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2020 07:46 AM
Ideal way to set the choice field is using the choice value;
The display value i.e. choice label may change as per business requirement so I would suggest using choice value
If this is before update then remove current.update() as it is not best practice
current.state = 2;
Regards
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
07-26-2020 11:07 PM
You cannot set the state value using setDisplayValue() for drop down.
You need to set it directly as below then only it will work
current.state = 2;
Regards
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
07-24-2020 07:46 AM
Ideal way to set the choice field is using the choice value;
The display value i.e. choice label may change as per business requirement so I would suggest using choice value
If this is before update then remove current.update() as it is not best practice
current.state = 2;
Regards
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
07-24-2020 08:05 AM
my business req is to display value Work In progress. I will discuss to my leads. kindly if you have another way . thank u
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2020 08:14 AM
Hi,
That is not how choice values are said as per my previous comment.
Please check with the team as well.
You need to set the value using the choice value only and not label
current.state = 2;
Also remove current.update()
Regards
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-14-2022 12:23 PM
I used to set choice using current.impact=2 and add current.update() method so it worked.
Thank you. it is helpful.
regards
urmila mane