- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2020 08:54 AM
Hi,
How can we achieve code for the below requirement
Create Child Tasks (Run Script – Type)
Create task function – Use Script Include here and pass the RITM number as parameter to script include.
Create a catalog task to this RITM as parent.
Tasks Fields to be mapped
Request Item – RITM number
Task requested for – RITM requested for
Task Short description – RITM Short Description
Task Description – RITM Description
Task State -- Open
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2020 10:23 PM
@SHAIK
Just to inform sc_task table doesn't have requested_for field. RITM table also doesn't have requested_for.
requested_for is present on sc_request table
Refer sample script below
I am passing the current object i.e. RITM object so that you can easily dot walk in script include function and get the values and set on sc task
Script Include:
var CreateTasks = Class.create();
CreateTasks.prototype = {
initialize: function() {
},
createTaskFromWorkflow: function(ritmObj){
var scTask = new GlideRecord('sc_task');
scTask.initialize();
scTask.request_item = ritmObj.sys_id;
scTask.short_description = ritmObj.short_description;
scTask.description = ritmObj.description;
scTask.request = ritm.request;
//scTask.requested_for = ritmObj.request.requested_for; // if you are using custom field on sc_task then use that here
scTask.insert();
},
type: 'CreateTasks'
};
How to call from workflow run script
new CreateTasks().createTaskFromWorkflow(current);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2020 07:15 PM
Hi - You can build a flow to automate this process. No script required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2020 08:20 PM
Hi,
We are using workflows
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2020 10:23 PM
@SHAIK
Just to inform sc_task table doesn't have requested_for field. RITM table also doesn't have requested_for.
requested_for is present on sc_request table
Refer sample script below
I am passing the current object i.e. RITM object so that you can easily dot walk in script include function and get the values and set on sc task
Script Include:
var CreateTasks = Class.create();
CreateTasks.prototype = {
initialize: function() {
},
createTaskFromWorkflow: function(ritmObj){
var scTask = new GlideRecord('sc_task');
scTask.initialize();
scTask.request_item = ritmObj.sys_id;
scTask.short_description = ritmObj.short_description;
scTask.description = ritmObj.description;
scTask.request = ritm.request;
//scTask.requested_for = ritmObj.request.requested_for; // if you are using custom field on sc_task then use that here
scTask.insert();
},
type: 'CreateTasks'
};
How to call from workflow run script
new CreateTasks().createTaskFromWorkflow(current);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2020 03:34 AM
@SHAIK
Thanks for marking my response as helpful.
Let me know if I have answered your question.
If so, please mark my response as correct & helpful so that this thread can be closed and others can be benefited by this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader