- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 01:36 AM
Hi,
I have developed a catalog item which when filled and submitted would create a Request and RITM under it. Along with this, I want a Catalog Task to be automatically created with a description "Default Task".
I am quite new to Servicenow and unable to find a way to solve this. Please help.
Thanks in advance.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 02:26 AM
Oh My Mistake.
Try this:
- var gr = new GlideRecord('sc_task');
- gr.initialize();
- gr.request_item = current.sys_id;
- gr.short_description = "Sample Description";
- gr.description = "Sample Description"
- gr.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 02:27 AM
var gr = new GlideRecord('sc_task');
gr.initialize();
gr.short_description = 'Demo';
gr.request_item = current.getValue(sys_id);
gr.insert();
You must pass the RITM also so that it appears in the related list of the RITM.
And initialize if used after the variable set then it just wipes away the set fields. Hope this helps
Please read and use this if needed GlideRecord Cheat Sheet - ServiceHow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 02:30 AM
var gr = new GlideRecord('sc_task');
gr.initialize();
gr.short_description = 'Demo';
gr.request_item = current.getValue(sys_id);
gr.insert();
You must pass the RITM also so that it appears in the related list of the RITM.
And initialize if used after the variable set then it just wipes away the set fields. Hope this helps
Please read and use this if needed GlideRecord Cheat Sheet - ServiceHow
Regards
SR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 02:44 AM
Hi Surendra,
I have used your script too. But, it is not creating a Catalog Task.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 03:12 AM
Use below script:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sc_task');
gr.initialize();
gr.short_description = 'Demo short description';
gr.description = "Test description";
gr.request_item = current.sys_id;
gr.parent = current.sys_id;
gr.insert();
})(current, previous);
And below conditions in the BR,