- 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 10:44 AM
On this line, try using the sys_id of 'Special Software'
if (requestType == 'Special Software') {
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2017 11:04 AM
I don't think that solution will work for us for a few reasons:
1. This program will be moved across various environments (Dev -> Test -> Prod). As I understand it, the sys_ids could be different in different environments. We need to make sure this works in all environments, regardless of what sys_ids what might be.
2. There are actually multiple records in the reference table with that value. The table that it is referencing is actually a Cross-Reference table of two other tables. We have a Location table and a Services Offered table. Different locations offer a different mixture of services. This Cross-Reference tables lists the locations and what services they offer. So based on what Location they select, this Cross Reference table is filtered to only show the Services Offered at that particular location.
So I think this really needs to run off of the displayed name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2017 11:25 AM
Display Names can change, but sys_id's will remain the same across all instances if you move them via Update Sets.
From personal experience, I will warn you that you're going to have a horrible time when someone tells you that you need to make some changes to a display name that is referenced in a workflow. At that point, you need to figure out how to adjust any open workflows you might have that reference these objects by name.
With that being said, I'm not entirely sure how you should proceed. I don't think you can dot-walk catalog variables (I may be wrong), so your best bet may be a quick glide lookup to see if you have a match.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2017 11:37 AM
What is more likely than a display name being changed is that new locations will be added, which would mean more records being added to the Cross Reference table, which would be even harder to maintain (someone would need to update the Workflow to add the additional sys_ids to check for). Even if we do not add new records, if we use sys_ids, we still have to check for multiple options, where as if we are able to use Display names, we only need to look for one Display name.
For example, this Cross Reference table may look something like the following. As you can see, there are already three different records that have "Special Software" in the Service Offered field, and more might be added as additional Locations are added in the future.
Location | Service Offered |
North | Phone |
North | Mobile |
North | Special Software |
North | Pager |
South | Phone |
South | Special Software |
South | Pager |
East | Mobile |
East | Special Software |