- 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 10:11 AM
OK. So that returned:
*** Script: d89ef6a70f56a2004f8322d8b1050e3a
That field name in the Cross Table is "Service", which is, a referenced field back to the "Services" table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 10:20 AM
Oh , so if i understand correctly you have another dependent table , from which you get the values.
I believe you can reach to the table with values in the same fashion (by dot walking). Let me know if you need any help in getting the script completed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 10:44 AM
OK. So this is baffling. I made the change to the background script you gave me like this:
var gr = new GlideRecord('sc_req_item');
gr.addQuery('number','RITM0010549')
gr.query();
while(gr.next()){
gs.print(gr.variables.u_request_type.service.service_name);
}
and it correctly returned a value of "Avaya Software", which is exactly what I am looking for.
So I updated my original script to this:
answer = ifScript();
var requestType = current.variables.u_request_type.service.service_name;
function ifScript() {
if (requestType == 'Avaya Software') {
return 'yes';
} else {
return 'no';
}
}
But it keeps evaluating to 'no'!
What am I doing wrong?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 10:48 AM
try this
answer = ifScript();
function ifScript() {
if (current.variables.u_request_type.service.service_name) {
return 'yes';
} else {
return 'no';
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 11:05 AM
Yes! That worked!
Can you explain why?
Does the value of the variable need to be set within the function?