- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 08:49 PM
I have created workflow as per requirement if after creation of catalog task to fulfillment group Servicenow group up to here is fine.
After that I have kept the If condition Please help me how to kept the if condition for this requirement.
catalog task state value:
completed == 15
Cancelled == 77
Requirement is if catalog task is
completed then request item(ritm) is set value closed complete
if catalog task is
Cancelled the request item (ritm) is set value to closed incomplete
Please find the attachment for your reference to get clear idea about this.
main concern is how to write script for if condition for this requirement please help me regarding this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 09:14 PM
Hi @chandra sekhar8 ,
script you can use to write the if condition for your requirement:
function if_condition(catalog_task_state) {
if (catalog_task_state == 15) {
request_item_state = "closed complete";
} else if (catalog_task_state == 77) {
request_item_state = "closed incomplete";
} else {
request_item_state = "unknown";
}
return request_item_state;
}
This script first checks the value of the catalog_task_state variable. If the value is 15, then the script sets the request_item_state variable to "closed complete". If the value is 77, then the script sets the request_item_state variable to "closed incomplete". Otherwise, the script sets the request_item_state variable to "unknown".
To use this script, you would need to call it from your workflow. For example, you could use the following code:
request_item_state = if_condition(catalog_task_state);
This code would call the if_condition() function and pass the value of the catalog_task_state variable to it. The if_condition() function would then return the appropriate value for the request_item_state variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 10:15 PM - edited 08-03-2023 10:16 PM
You can just add condition in catalog task activity itself to check the state value shown as below.
Step 1 : In catalog task activity , Select "wait for completion" checkbox
Step 2 : Scroll down in catalog task activity and in Related links select 'Condition'
Step 3 : Remove the always condition and add below conditions
The state value taken in my case are OOTB , You can check if this works for your custom values.
or else you need to explicitly write a code to make RITM closed incomplete or complete.
Thanks
Vishal B
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 09:14 PM
Hi @chandra sekhar8 ,
script you can use to write the if condition for your requirement:
function if_condition(catalog_task_state) {
if (catalog_task_state == 15) {
request_item_state = "closed complete";
} else if (catalog_task_state == 77) {
request_item_state = "closed incomplete";
} else {
request_item_state = "unknown";
}
return request_item_state;
}
This script first checks the value of the catalog_task_state variable. If the value is 15, then the script sets the request_item_state variable to "closed complete". If the value is 77, then the script sets the request_item_state variable to "closed incomplete". Otherwise, the script sets the request_item_state variable to "unknown".
To use this script, you would need to call it from your workflow. For example, you could use the following code:
request_item_state = if_condition(catalog_task_state);
This code would call the if_condition() function and pass the value of the catalog_task_state variable to it. The if_condition() function would then return the appropriate value for the request_item_state variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 10:15 PM - edited 08-03-2023 10:16 PM
You can just add condition in catalog task activity itself to check the state value shown as below.
Step 1 : In catalog task activity , Select "wait for completion" checkbox
Step 2 : Scroll down in catalog task activity and in Related links select 'Condition'
Step 3 : Remove the always condition and add below conditions
The state value taken in my case are OOTB , You can check if this works for your custom values.
or else you need to explicitly write a code to make RITM closed incomplete or complete.
Thanks
Vishal B
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates