- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 08:17 AM
When I create a new child ticket, I would like some field values from the parent ticket to automatically be populated into the child ticket. How do I achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2016 07:45 AM
Here is a script from a UI Action which creates a change request from an incident.
It will guide you through the main points of what you want to do.
var change = new GlideRecord("change_request");
//change.short_description = current.short_description;
//change.description = current.description;
change.cmdb_ci = current.cmdb_ci;
change.priority = current.priority;
var sysID = change.insert();var mySysID = current.update();
gs.addInfoMessage("Change " + change.number + " created");
var new_relationship = new GlideRecord('task_rel_task');
new_relationship.type = 'd798ba000a2581020048305ef5287403'; //use the sys_id of the relationship type from your instance here
new_relationship.parent = current.sys_id;
new_relationship.child = sysID;
new_relationship.insert();action.setRedirectURL(change);
action.setReturnURL(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2016 10:07 AM
You don't say if x_audi2_clm_table extends the task table, but if it does, you could set the parent field in the clm object to the current.sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2016 10:11 AM
That worked! Thanks Steve.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2016 09:35 AM
HI tmichals,
Try with this code:
Table: Incident
When: display
Advanced: true
Condition: current.isNewRecord() && !current.parent_incident.nil()
Script:
current.cmdb_ci = current.parent_incident.cmdb_ci;
current.category = current.parent_incident.category;
current.subcategory = current.parent_incident.subcategory;
current.contact_type = current.parent_incident.contact_type;
var comments = current.parent_incident.comments.getJournalEntry(-1);
var cmts = comments.split("(Additional comments)\n");
current.comments = cmts[cmts.length-1];