- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 05:30 AM
Hi ServiceNow Experts,
My requirement is to create a change task, when the change request short description contains "Planned Outage". I have written the below script. Can you please help me with this, as change task is not being triggered.
createTask();
function createTask() {
var org = current.u_organization;
var groupName = '';
if (org == 'IT') {
groupName = 'IT-Network Operations';
var cTask = new GlideRecord('change_task');
cTask.initialize();
cTask.short_description = 'Change task should have test and verify';
// cTask.description = '';
cTask.parent = current.sys_id;
cTask.change_request = current.sys_id;
cTask.cmdb_ci = current.cmdb_ci;
cTask.u_predecessor = 'No';
cTask.assignment_group.setDisplayValue(groupName);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 05:52 AM
Can you try this:
createTask();
function createTask() {
var org = current.u_organization;
var groupName = '';
if (org == 'IT') {
groupName = 'IT-Network Operations';
var cTask = new GlideRecord('change_task');
cTask.initialize();
cTask.short_description = 'Change task should have test and verify';
// cTask.description = '';
cTask.parent = current.sys_id;
cTask.change_request = current.sys_id;
cTask.cmdb_ci = current.cmdb_ci;
cTask.u_predecessor = 'No';
cTask.assignment_group.setDisplayValue(groupName);
cTask.insert();
}
}
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 05:47 AM
Hi Priyanka,
Could you add logs to your Business Rule and check if BR is triggering or not.. Also check what does logs show.
Mark my Response as Correct or Helpful, if you find it Appropriate.
Regards,
Sravani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 05:52 AM
Can you try this:
createTask();
function createTask() {
var org = current.u_organization;
var groupName = '';
if (org == 'IT') {
groupName = 'IT-Network Operations';
var cTask = new GlideRecord('change_task');
cTask.initialize();
cTask.short_description = 'Change task should have test and verify';
// cTask.description = '';
cTask.parent = current.sys_id;
cTask.change_request = current.sys_id;
cTask.cmdb_ci = current.cmdb_ci;
cTask.u_predecessor = 'No';
cTask.assignment_group.setDisplayValue(groupName);
cTask.insert();
}
}
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 06:14 AM
Hi Murthy,
I added cTask.inser(); still task isn't appearing.
Regards,
Priyanka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 07:13 AM
Ok
Have you added logs? and when do you want to create a change task? right after creation of the change request?
If yes use after insert BR and try
Hope it helps
Thanks
Murthy
Murthy