- 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:09 AM
I guess if (current.variables.u_request_type.service.service_name) will return 'true' whenever there is a value in that variable, did you get a chance to test the negative (no) functionality?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 11:16 AM
I spoke too soon. You are correct. I picked some other Service, and this expression incorrectly evaluated to 'yes'. So it is not working correctly.
Before, everything was evaluating to 'no'. Now everything is evaluating to 'yes'.
Back to the drawing board...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 10:58 AM
I hope your workflow is running on the req_item table. Can you please add logging in workflow to see , what value you are getting in the requestType variable you are creating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 11:17 AM
Yes, it is running on the sc_req_item table.
You will have to forgive me, I am a bit new to Java programming. What is the best way of adding logging?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2017 11:23 AM
You can try with the gs.log
gs.log('variable value'+requestType);
gs.log('variable value from task'+current.variables.u_request_type.service.service_name);
add the above 2 lines to your script and then see what values you see in the system logs against these log statements.
There is also workflow specific logging, which i haven't used so far.