- 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-09-2017 01:03 PM
Can you try this background script to see the value stored in the variable?
var gr = new GlideRecord('sc_req_item');
gr.addQuery('number','<RITM #>')
gr.query();
while(gr.next()){
gs.print(gr.variables.u_request_type);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2017 01:11 PM
I will have to read up on Background Scripts, I have never done them before.
Note that u_request_type is just a Variable in my Service Catalog. It is not stored in the sc_req_item table.
I got pulled off on an important project, so probably won't be able to pick this up again until morning.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2017 01:39 PM
Hi Joe, you can just replace the RITM # in my script (tested) and execute it in the background.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 09:57 AM
OK. Just getting back to this now. I ran it and it returned the following:
*** Script: 0b49e1543766ee0047559b7a93990e35
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 10:03 AM
Okie, i wanted to see if you are getting sys id or name.Now , you should be able to get the value (special software... ) by .u_name ( or the field that has the name value in your dependent table).
var gr = new GlideRecord('sc_req_item');
gr.addQuery('number','<RITM #>')
gr.query();
while(gr.next()){
gs.print(gr.variables.u_request_type.u_name);
}
try this