- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2018 01:05 PM
Please find the below code
i tried this code but wont' work
var incident = new GlideRecord("incident");
//change.short_description = current.short_description;
incident.initialize();
incident.short_description = current.short_description;
incident.description = current.description;
incident.cmdb_ci = current.cmdb_ci;
incident.priority = current.priority;
incident.caller_id = current.requested_for;
incident.opened_by = current.opened_by;
var sysID = incident.insert();
var mySysID = current.update();
gs.addInfoMessage("incident " + incident.number + " created");
//function onCreateChildIncident(){
//NOW._createChildIncident(g_form.getUniqueValue());
//}
//current.sc_req_item_state = State.cancel;
current.update();
current.cancel_sc_req_item = gs.getUserID();
//gs.addInfoMessage("incident" + incident.number + "has been created" );
action.setRedirectURL(current);
//action.setReturnURL(current);
If i click on create a incident then child incident should be updated into below child incident table
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2018 04:07 AM
This should probably work, note that there are 2 different parent fields on incident table, either parent or parent incident. It seems like you are displaying the Parent Incident related list so that's the field you need to set on the child incident.
You had 2 current.update() in your code which isn't needed, and the two variables you set wasn't used so I removed them. not sure what the current.cancel_sc_req_item does in the code but I left it there since you had it. But it should probably not be there.
var incident = new GlideRecord("incident");
incident.initialize();
incident.short_description = current.short_description;
incident.description = current.description;
incident.cmdb_ci = current.cmdb_ci;
incident.priority = current.priority;
incident.caller_id = current.requested_for;
incident.opened_by = current.opened_by;
incident.parent_incident = current.getUniqueValue(); //This is what add the parent relation to the current record.
var sysID = incident.insert();
gs.addInfoMessage("Incident " + incident.number + " created");
current.cancel_sc_req_item = gs.getUserID();
current.update();
action.setRedirectURL(current);
Please mark as Helpful/Correct if this helps or solve the problem.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2018 03:44 AM
Try this is working for me
var incident = new GlideRecord("incident");
incident.initialize();
incident.short_description = current.short_description;
incident.description = current.description;
incident.cmdb_ci = current.cmdb_ci;
incident.priority = current.priority;
incident.caller_id = current.requested_for;
incident.opened_by = current.opened_by;
incident.parent_incident = current.sys_id;
incident.insert();
action.setRedirectURL(current);
Mark as correct or helpful based on the impact.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2018 04:07 AM
This should probably work, note that there are 2 different parent fields on incident table, either parent or parent incident. It seems like you are displaying the Parent Incident related list so that's the field you need to set on the child incident.
You had 2 current.update() in your code which isn't needed, and the two variables you set wasn't used so I removed them. not sure what the current.cancel_sc_req_item does in the code but I left it there since you had it. But it should probably not be there.
var incident = new GlideRecord("incident");
incident.initialize();
incident.short_description = current.short_description;
incident.description = current.description;
incident.cmdb_ci = current.cmdb_ci;
incident.priority = current.priority;
incident.caller_id = current.requested_for;
incident.opened_by = current.opened_by;
incident.parent_incident = current.getUniqueValue(); //This is what add the parent relation to the current record.
var sysID = incident.insert();
gs.addInfoMessage("Incident " + incident.number + " created");
current.cancel_sc_req_item = gs.getUserID();
current.update();
action.setRedirectURL(current);
Please mark as Helpful/Correct if this helps or solve the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2018 04:18 AM
Thanks you much
working good
Regards
kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2018 04:19 AM
Good that it solved your problem.