How do I map field values from a parent ticket to a new child ticket?

Tyler Michals
Kilo Guru

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?

1 ACCEPTED SOLUTION

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);


View solution in original post

12 REPLIES 12

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.


That worked! Thanks Steve.


Naga Surendra 1
Mega Expert

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];