- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2017 10:42 AM
We have a Service Catalog to request various Telecom Requests. I am building a Workflow, based on the Requested Item that is created from the Request. I am trying to add an IF Action that checks to see if the request was for some special software (in which case, I will then use Create Task to create a task fro the software installation).
So, on the Service Catalog, the variable for the requested item is named u_request_type, and it is a Reference Field to the table which contains the various request selections. The code for my IF action looks like this:
answer = ifScript();
var requestType = current.variables.u_request_type;
function ifScript() {
if (requestType == 'Special Software') {
return 'yes';
} else {
return 'no';
}
}
Needless to say, it doesn't work. I think it is because the u_request_type is a reference field to another table.
So, how do I get the displayed value for this field? Do I need to dot-walk, or somehow use GetDisplayName?
Not sure exactly what the code for that needs to look like.
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 01:51 PM
My and Joe, i completely over looked your ifScript function . Your script looks good to me. Lets try one last thing here , for the if
if(current.variables.u_request_type.service.service_name.indexOf('Avaya Software') > -1){
return 'yes';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 11:37 AM
OK, so I updated my script like so:
answer = ifScript();
var requestType = current.variables.u_request_type.service.service_name;
function ifScript() {
if (requestType == 'Avaya Software') {
return 'yes';
} else {
return 'no';
}
}
gs.log('variable value'+requestType);
gs.log('variable value from task'+current.variables.u_request_type.service.service_name);
And it returned the following:
variable value from taskAvaya Software
variable valueAvaya Software
So that looks like it should be working, but it keeps evaluating to 'no' (see image below):
What could be going on here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 12:15 PM
So, your script feeds to if, and if creates task. Am i correct??
What is your condition in 'if'??
If i may recommend, can you consider using switch statements instead of 'if'?
Sent from my iPhone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 12:24 PM
The Condition box in the IF action is blank, because I have the Advanced box is checked, and the Script in there is this script we have been trying to get in this thread here. It should return "Yes" if it is an "Avaya Software" request, and then create the Task.
Regardless of whether we would be using IF or Switch, isn't it the same problem? How to check for the request type?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 01:51 PM
My and Joe, i completely over looked your ifScript function . Your script looks good to me. Lets try one last thing here , for the if
if(current.variables.u_request_type.service.service_name.indexOf('Avaya Software') > -1){
return 'yes';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2017 06:46 AM
Yes! That seems to work!
Thank you so much!
Do you have any idea why this version worked, but the others did not?
We thought maybe there was an extra blank space at the end of "Avaya Software", but we confirmed that it does not.
Might it have anything to do with the fact that we are referring to a reference field that refers to another reference field?