
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2019 02:45 PM
We have a requirement to stop the OOB Copy change UI Action from copying change tasks, as the tasks get triggered naturally through the change workflow.
Looking at the 'Copy Change' UI action script - it does not refer to the copying of tasks. The script include called in the UI Action - 'ChangeUtils' also does not refer to copying the tasks. I've also checked Change Properties and there is nowhere to disable the copying of change tasks.
I've located a community thread with instructions to created a new UI action for copy change. I've used this as a basis to create my own UI action but the condition 'gs.hasRole(“itil”) && current.isValidRecord()' did not work. Mine is as follows, but for some reason it is also still copying tasks:
Onclick: OnCopyChangeClick()
Condition: gs.hasRole('itil')&&ChangeUtils.isCopyChangeEnabled(current)
Script:
var chgID = current.sys_id.toString();
var newChange = new GlideRecord('change_request');
newChange.initialize();
//copy existing change fields
newChange.short_description = current.short_description;
newChange.requested_by = current.requested_by;
newChange.category = current.category;
//newChange.business_service = current.business_service; not creating have created new function
newChange.type = current.type;
newChange.assignment_group = current.assignment_group;
newChange.assigned_to = current.assigned_to;
newChange.description = current.description;
newChange.risk = current.risk;
newChange.urgency = current.urgency;
newChange.reason = current.reason; //is not copying
newChange.justification = current.justification; //is not copying
newChange.implementation_plan = current.implementation_plan; //is not copying
newChange.risk_impact_analysis = current.risk_impact_analysis; //is not copying
newChange.test_plan = current.test_plan;
newChange.backout_plan = current.backout_plan;
newChange.u_will_this_change_cause_downtime = current.u_will_this_change_cause_downtime;
newChange.u_is_this_change_related_to_a_project = current.u_is_this_change_related_to_a_project; //is not copying
newChange.insert();
//Copy attachments for this change
if (typeof GlideSysAttachment != 'undefined')
GlideSysAttachment.copy('change_request', chgID, 'change_request', newChange.sys_id);
else
Packages.com.glide.ui.SysAttachment.copy('change_request', chgID, 'change_request', newChange.sys_id);
//copyTask();
copyCI();
copyService();
gs.addInfoMessage('Change ticket ' + newChange.number + ' created.');
action.setRedirectURL(newChange);
function copyCI() {
//Copy over the affected CI list
var currentCI = new GlideRecord('task_ci');
currentCI.addQuery('task', current.sys_id);
currentCI.addNullQuery('u_ci_group'); //Added to ensure that copying does not duplicate Group CIs
currentCI.query();
while(currentCI.next()){
var newCI = new GlideRecord('task_ci');
newCI.initialize();
newCI.task = newChange.sys_id;
newCI.ci_item = currentCI.ci_item;
newCI.insert();
}
}
//copy the current business service
function copyService() {
var currentService = new GlideRecord('cmdb_ci_service');
currentService.addQuery('name', current.sys_id);
currentService.query();
while(currentService.next()){
var newService = new GlideRecord('cmdb_ci_service');
newService.initialize();
newService.name = newChange.sys_id;
newService.cmdb_ci_service = currentService;
newService.insert();
}}
Any ideas?
Many thanks,
Anna
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2019 03:22 PM
Try finding this property and remove the change tasks: com.snc.change_request.copy.related_lists
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2022 10:17 AM
Hi Kristenankeny, I know this is a bit of an old thread but can you further explain how to find the property to remove "change tasks: com.snc.change_request.copy.related_lists" in order to resolve the issue of change tasks being created when copying a change.
Would appreciate your feedback as I am a new ServiceNow developer trying to resolve a similar issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2022 10:39 AM
I got it figured out. Thanks so much for sharing this helpful solution