- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2022 05:54 AM
Hello All,
I am trying to create duplicate Catalog task in RITM using workflow run script but it is not working.
Could you please help me on this issue.
I am using this below script on workflow run script for creating catalog task, but it is not working.
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item',current.sys_id);
gs.info("Sys ID " + current.sys_id);
while(gr.next())
{
var sd = "Short Description: "+ gr.short_description;
var d = "Description: "+ gr.description;
var r = new GlideRecord('sc_task');
gs.info("Number " + gr.number);
r.initialize();
r.short_description = sd;
r.description = d;
r.state = 1;
r.name = gr.name;
r.requested_for = gr.requested_for;
r.priority = gr.priority;
r.assignment_group = gr.assignment_group;
r.request_item = current.sys_id;
r.request = gr.request;
r.insert();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2022 06:13 AM
Hello
you need to mark two changes to your script
1) Add gr.query();
2) You need not map requested for field as its coming from Request-->RITM->catalog task so it will be same as RTIM even if you don't map
try below script
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item',current.sys_id);
gr.query()
gs.info("Sys ID " + current.sys_id);
while(gr.next())
{
var sd = "Short Description: "+ gr.short_description;
var d = "Description: "+ gr.description;
var r = new GlideRecord('sc_task');
gs.info("Number " + gr.number);
r.initialize();
r.short_description = sd;
r.description = d;
r.state = 1;
r.name = gr.name;
r.priority = gr.priority;
r.assignment_group = gr.assignment_group;
r.request_item = current.sys_id;
r.request = gr.request;
r.insert();
}
Please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2022 06:07 AM
Hi Swamy,
You have not queried the table. Please add gr.query() after gr.addQuery('request_item',current.sys_id); and your code will work.
Please mark correct if helpful.
Regards,
Vaibhav Dane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2022 06:13 AM
Hello
you need to mark two changes to your script
1) Add gr.query();
2) You need not map requested for field as its coming from Request-->RITM->catalog task so it will be same as RTIM even if you don't map
try below script
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item',current.sys_id);
gr.query()
gs.info("Sys ID " + current.sys_id);
while(gr.next())
{
var sd = "Short Description: "+ gr.short_description;
var d = "Description: "+ gr.description;
var r = new GlideRecord('sc_task');
gs.info("Number " + gr.number);
r.initialize();
r.short_description = sd;
r.description = d;
r.state = 1;
r.name = gr.name;
r.priority = gr.priority;
r.assignment_group = gr.assignment_group;
r.request_item = current.sys_id;
r.request = gr.request;
r.insert();
}
Please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2022 07:04 AM
thanks for all those who replied me