Execution Plans Based on Request Variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2011 12:03 PM
Hi all,
I'm trying to create an execution plan which will execute certain tasks based on the values of variables in the requested item. It seemed like this Wiki article had the answer under "Advanced Options":
http://wiki.service-now.com/index.php?title=Applying_Conditions_to_your_Execution_Plan_Tasks#Advance...
I used basically the same exact script that's in that article:
var rc = false;
if (current.sc_req_item.request.DeviceType == 'Other Unix Server'){
rc = true;
}
rc;
I'm getting the following error message:
Error:
Problem at line 5 character 1: Expected an assignment or function call and instead saw an expression.
rc;
Does anyone know what I may be doing wrong here? I've tried changing the last line to "return rc;" but then I'm getting an error saying "Invalid return".
Any help is greatly appreciated.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2011 02:21 PM
In order to return a value it needs to be part of a function.
In your script you're setting a variable to true or false but nothing is being returned
Try something similar to this
rc = myFunction();
function myFunction(){
if (current.sc_req_item.request.DeviceType == 'Other Unix Server'){
return 'yes'; // or return true
}
else {
return 'no'; // or return false
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2011 06:43 AM
This is getting closer to what I'm trying to do, but I still can't seem to satisfy the condition to return a "true" value. If I reverse the true/false in the if/else statement I get a true value, and the task executes so I'm sure that the condition isn't being satisfied and this return works.
I've tried re-writing this numerous ways, but nothing seems to work. From looking at the database tables I'm trying to match the if-condition with the 'value' column in the 'sc_item_option' table, but I'm not sure how to refer to that column in the if statement.
I can't seem to find a wiki article or community forum discussion about writing an execution plan task condition script that will trigger based on a value in one of the request item variables. The Wiki article I cited in my original post contained a condition script that compared a value against the current.request_item.request.requested_for.name variable. If I'm reading this correctly then "current" should be the sc_item_option_mtom table, and request_item is the parent of that table. If that's correct then I'm trying to compare my variable to current.sc_item_option.value column, and sc_item_option is the dependent of the sc_item_option_mtom table. I just need to make sure I compare against the correct sys_id record in the sc_item_option table.
This has been beating me up for a couple of days. Maybe I'm way off on which table "current" is referring to and/or how to refer to the record I'm trying to compare my condition to. If anyone is able to help or point me in the right direction I thank you greatly. This functionality is critical to our implementation of the service catalog.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2011 02:33 AM
You can acces the variables by refering to the variable_pool (current.variable_pool.var_name)
Condition script:
current.variable_pool.DeviceType == 'Other Unix Server'
will run the task if the DeviceType is Other Unix Server.