- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2017 11:12 AM
var ci = current.variables.cmdb_ci.getDisplayValue();
gs.log('CI' + ci);
if(ci)
{
var techSupport = ci.support_group;
gs.log('This is the support group' + techSupport);
task.assignment_group = techSupport;
}
else {
task.assignment_group = '9d7cbca24fb271007a990f5e9310c7e9';
}
I'm missing something fairly easy here, in the above code, my variable "techSupport" is always undefined. I'm using this script in the workflow activity to assign the task to a group based on the ci's support group(field named support_group on the ci form) if a ci is selected or assign to a defined group if its empty. The second part works. I cannot seem to get the value of the support group field for the ci on the item. I've tried getDisplayValue() with no luck.
Appreciate your help!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2017 11:24 AM
Try this
- if(current.variables.cmdb_ci)
- {
- gs.log('This is the support group' + current.variables.cmdb_ci.support_group);
- task.assignment_group = current.variables.cmdb_ci.support_group;
- }
- else {
- task.assignment_group = '9d7cbca24fb271007a990f5e9310c7e9';
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2017 11:24 AM
Try this
- if(current.variables.cmdb_ci)
- {
- gs.log('This is the support group' + current.variables.cmdb_ci.support_group);
- task.assignment_group = current.variables.cmdb_ci.support_group;
- }
- else {
- task.assignment_group = '9d7cbca24fb271007a990f5e9310c7e9';
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2017 11:32 AM
I could swear that is what I started with and it didn't work so I started overthinking it but this worked like a charm! Thanks!
Any insight as to why this works without getting the display value of the ci?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2017 11:44 AM
We don't need display value since we are just going to use dotwalking concept to get the glide values of the cmdb-ci reference field. display value will give the name of the CI and i think using that it won't help us to access the gliderecord of the same field instead of with sys_id of the CI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2017 11:58 AM
Agree with Shishir. You dont need display value to get to the sys id. you can just dot walk to the field and use it.