- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2020 04:00 PM
Hello,
I'm trying to create a workflow if condition to check if the requested_for.manager field is empty. I used the following script, but it's not working:
answer = ifScript();
function ifScript() {
if (current.requested_for.manager != '') {
return 'yes';
}
return 'no';
}
The goal is to branch out and cancel the request before manager approval if the user's manager field is empty.
Thank you!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2020 04:05 PM
Is this flow running on the sc_req_item or sc_request table? If the requested_for is the name of a catalog item variable you need to use current.variables.requested_for
answer = ifScript();
function ifScript() {
if (gs.nil(current.variables.requested_for.manager)) {
//if empty.
return 'yes';
}
return 'no';
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2020 04:05 PM
Is this flow running on the sc_req_item or sc_request table? If the requested_for is the name of a catalog item variable you need to use current.variables.requested_for
answer = ifScript();
function ifScript() {
if (gs.nil(current.variables.requested_for.manager)) {
//if empty.
return 'yes';
}
return 'no';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2020 04:48 PM
Thank you, Kieran! This worked out great.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2021 09:49 AM
This worked great for me as well. I was needing to do something very similar and once I used the API gs.nil, it worked perfectly. I've been trying other scripting with == null but it was not working.
I was not aware about gs.nil so thanks for this.
I'm not strong in javascript so I'll remember to use this one when null values need to be determined.
Brandon