How to auto-populate incident field in incident_task table ?

ujjwal_5181
Tera Contributor

How to auto-populate incident number of incident table to incident field of incident_task table ? 

6 REPLIES 6

Kishore Aregila
Tera Contributor

@ujjwal_5181 

 Use this Script in Business Rule

 

var task= new GlideAggregate('incident_task');
task.initialize();
task.parent = current.sys_id;
task.incident = current.sys_id;

task.insert();

Thanks for replying @Kishore Aregila

There may have been a miscommunication, let me clarify what I meant. My requirement was quite different I meant to say that once I click on "new"  button in the related list of Incident form to create a new Incident Task then one of the field in Incident Task form named 'incident' must auto-populate its value with the parent Incident number. Like if Incident form has Incident number: INC00000101 then the incident task form must auto-populate this value in its incident field on load.

I had written a client-script for this and it worked for me.

Client Script:

Table: Incident Task

Type : onLoad

function onLoad() {
var gURL = new GlideURL();
gURL.setFromCurrent();
var incidentNum = gURL.getParam("sysparm_collectionID");
if(incidentNum!=undefined) {
g_form.setValue('incident',decodeURI(incidentNum));
}

}