
- 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-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();
}