- 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 06:27 AM
Hello,
You will use an after business rule, please follow the steps :
(function executeRule(current, previous /*null when async*/ ) {
createTask();
function createTask() {
var org = current.u_organization; // if u_organisation is a string field
var groupName = '';
if (org == 'IT') {
groupName = 'Service Desk'; // please put the name of your group
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();
}
}
})(current, previous);
Regards,
Hajar