
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2019 12:27 PM
Hi folks,
I have a catalog item that allows a user to request application access. This is the workflow I'm using:
I use this "Group Assignment" script to create the tasks based on the applications selected:
var app = new GlideRecord('cmdb_ci_appl'); app.addQuery('sys_id', 'IN', current.variables.select_applications); app.query(); while(app.next()){ var sctask = new GlideRecord('sc_task'); sctask.initialize(); sctask.request_item = current.sys_id; sctask.assignment_group = app.getValue('support_group'); //continue to populate other information like description, etc... sctask.short_description = "Application Request for " +current.request.requested_for.getDisplayValue(); sctask.insert(); } |
But the task it creates don't have the variables from the RITM. One of the variables is a reference field called "Mirror User" (v_mirror_user). I've tried to add them (below sctask.short_description) using:
sctask.v_mirror_user=current.request.v_mirror_user.getDisplayValue(); sctask.v_mirror_user=current.request.v_mirror_user; sctask.v_mirror_user=current.variables.v_mirror_user.getDisplayValue(); sctask.v_mirror_user=current.variables.v_mirror_user; |
The v_mirror_user field would normally be added at the variables part of the catalog task:
But since this isn't a catalog task, I'm figuring that's why nothing happens.
I tried creating the Run Script called "scratchpad" to put these values in the scratchpad using the current variables above and calling them from the "Group Assignment" script like above and still nothing. I'm guessing the answer is somewhere else.
I've run out of limited ideas and the last 4 hours of searching haven't helped.
Any ideas?
edit: This is the section I'm referring to. It's on the RITM, but not on the tasks:
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2020 10:32 AM
I ended up writing the variable to the scratchpad and it worked using this code:
var app = new GlideRecord('cmdb_ci_appl');
app.addQuery('sys_id', 'IN', current.variables.v_select_applications);
app.query();
while(app.next()){
var sctask = new GlideRecord('sc_task');
sctask.initialize();
sctask.request_item = current.sys_id;
sctask.assignment_group = app.getValue('support_group');
//continue to populate other information like description, etc...
sctask.short_description = "Grant Application Access for " +current.request.requested_for.getDisplayValue();
sctask.v_mirror_user = workflow.scratchpad.v_mirror_user;
sctask.insert();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2019 01:05 PM
When you are referring to catalog variables in script, you must use
current.variables.variable_name
Give that a try.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2019 01:22 PM
Hi,
Tried that, it doesn't display in the missing variables section. If I route the value to the "description" field on the task it shows, but I need the variables section to show up.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2019 08:09 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2019 12:15 PM
The Catalog item is an application request where users select n values from a list. When submitted the script creates a task for each application and assigns it to its support group based on the CMDB field. There are over 200 applications so generating via script seemed the best way. (I tried putting the script in a catalog task, but that failed.)
So the script part works fine, but the variables section is missing from the tasks and I need to know how to include them in this script.