
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2018 02:17 PM
Hello,
I have read a few ServiceNow articles and it appears you can get/pass Request Item variables to the Workflow Scratchpad OOB. Anyway having a problem or missing why I am not getting the value to the scratchpad.
So, on the sc_cat_item table, I created a new column called Manager Approval (u.manager.approval) [True/False]. This way on all our current catalog items a catalog admin can select if the Catalog item requires Manager Approval. In my workflow, I have the below IF condition to look to see if the Catalog item has the 'Manager Approval' checkbox set to True or False. But my workflow.scratchpad.u_manager_approval the variable is undefined. Am I missing something?
answer = ifScript();
var manApp = workflow.scratchpad.u_manager_approval;
//var manApp = current.variable_pool.u_manager_approval;
gs.info('manApp Value: ' + manApp); // returns 'undefined'
function ifScript() {
if (manApp == true) {
return 'yes';
}
return 'no';
}
gs.info('Answer Value: ' + answer); // returns 'no'
Here is an article that I referenced:
https://community.servicenow.com/community?id=community_question&sys_id=ddc013a9dbdcdbc01dcaf3231f9619f7
Thank you,
-Wesley
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2018 07:03 AM
I get it now, you can do this through filter condition, doesn't require scripting, like below, to check if manager field is true then if activity will return true else it will return false.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2018 03:17 PM
You are trying to capture the value after calling the function which will not be part of ifscript() function so it will not be able to validate the true/false condition in ifscript(). Please check if this helps.
if it's a variable on catalog item then please try with var manApp = current.variables.u_manager_approval;
if it's a field on sc_req_item table then please try with var manApp = current.u_manager_approval;
answer = ifScript();
function ifScript() {
//var manApp = current.variables.u_manager_approval; // Please uncomment this line if it's a variable on catalog item
//var manApp = current.u_manager_approval; // Please uncomment this line if it's a field on sc_req_item table
gs.info('manApp Value: ' + manApp);
if (manApp == true) {
return 'yes';
}
return 'no';
}
gs.info('Answer Value: ' + answer); // returns 'no'
Let's see if this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2018 11:23 PM
Hi Shishir,
I used your exact code and went and even created a variable on the catalog item itself called "u_manager_approval". Both:
var manApp = current.variables.u_manager_approval;
var manApp = current.u_manager_approval;
Come back as "undefined". Any other ideas?
Thank you,
-Wesley

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2018 12:22 AM
In you catalog, if the variable name is u.manager.approval, change it to u_manager_approval.
Then use
var manApp = current.variables.u_manager_approval;
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2018 12:39 AM
HI,
Can you tell me one thing. Do you have a variable called u_manager_approval on catalog item or Request form?
thanks,
Ashutosh Munot