- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2023 08:32 PM
Hello Team ,
I have a state field with options like draft , ready , work in progress , and 3 other fields . When a case is created it is automatically setting the state to draft state by using client script . My requirement is to hide all the other options when the case is on draft state and show only ready state and hide all the other options and make the state field readonly.
Solved! Go to Solution.
- Labels:
-
HR Service Delivery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2023 10:07 PM
@Ediga Sai Chand Create a new onload Client script on your table and add below code to it.
function onLoad() {
if (g_form.isNewRecord())
return;
var DRAFT = "1"; //Draft state value
var READY = "10";
var WORK_IN_PROGRESS = "18";
//Add other 3 state choice and values here as below
var FOURTH_CHOICE = "";
var FIFTH_CHOICE = "";
var SIXTH_CHOICE = "";
if (g_form.getValue("state") == DRAFT) {
g_form.removeOption("state", FOURTH_CHOICE);
g_form.removeOption("state", FIFTH_CHOICE);
g_form.removeOption("state", SIXTH_CHOICE);
}
}
Note: Add correct choice values for other 3 options in script
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2023 09:30 PM
You need to tweak the OOB client script "Restrict state changes".
Or you can create a separate one by following the about client script, which has to be valid only for Lifecycle events cases.
var REMOVE_DRAFT_TRANSITIONS = [AWAITING_APPROVAL, WORK_IN_PROGRESS, AWAITING_ACCEPTANCE]; //in this line you have to keep only Ready for work.
Please mark as correct/helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2023 10:07 PM
@Ediga Sai Chand Create a new onload Client script on your table and add below code to it.
function onLoad() {
if (g_form.isNewRecord())
return;
var DRAFT = "1"; //Draft state value
var READY = "10";
var WORK_IN_PROGRESS = "18";
//Add other 3 state choice and values here as below
var FOURTH_CHOICE = "";
var FIFTH_CHOICE = "";
var SIXTH_CHOICE = "";
if (g_form.getValue("state") == DRAFT) {
g_form.removeOption("state", FOURTH_CHOICE);
g_form.removeOption("state", FIFTH_CHOICE);
g_form.removeOption("state", SIXTH_CHOICE);
}
}
Note: Add correct choice values for other 3 options in script
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023