
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2019 10:22 PM
Hello All,
I have created a workflow using RunScript to create a catalog Task. Whenever I am submitting the Catalog, due to the workflow the task is getting created in sc_task table but is not attaching in the related list of RITM, which earlier used to happen when I did it without Run Script. Am I missing something here?
Please Help!
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2019 10:44 PM
As Tripti mentioned, its good to use Catalog Task block instead of runscript.
To your query, in the runscript after initializing the gliderecord you need add the below line gr.request_item = current.sys_id;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2019 10:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2019 10:44 PM
As Tripti mentioned, its good to use Catalog Task block instead of runscript.
To your query, in the runscript after initializing the gliderecord you need add the below line gr.request_item = current.sys_id;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2020 05:13 AM
You can check below code also in run script to create a task:
var gt = new GlideRecord('sc_task');
gt.initialize();
gt.request_item = current.sys_id;
gt.short_description = 'Short description';
gt.setDisplayValue('assignment_group' ,'Some Assignment Group');
gt.description ='Description of Task';
gt.u_task_duration = '2d';
var task_sys_id = gt.insert();
createVariables(task_sys_id);
function createVariables(task_sys_id)
{
var tsk = new GlideRecord('sc_task');
tsk.addQuery('sys_id',task_sys_id);
tsk.query();
while (tsk.next())
{
var reqvar = new GlideRecord('sc_item_option_mtom');
reqvar.addQuery('request_item',current.sys_id);
reqvar.query();
while (reqvar.next())
{
var variablereference = new GlideRecord('sc_item_option');
if (variablereference.get(reqvar.sc_item_option))
{
var add_task_var = new GlideRecord('sc_item_variables_task');
add_task_var.task = tsk.sys_id;
add_task_var.variable = variablereference.item_option_new;
add_task_var.insert();
}
}
}
}