Can we create copy incident similar to the copy change?

Sharique Azim
Mega Sage

Hi all,

We have seen the copy change ui button on the change_request table in SNOW which copies the record for future use.

My question is can we create a same for the incident table?If yes, what steps are required.

I have been referencing Configure ability to copy a change request   to better understand.

One of my biggest obstacle is to mimic the ChangeUtils() API to be used in the UI action.

Detail steps/codes would be highly appreciated.

Best regards,

Shariq

1 ACCEPTED SOLUTION

poyntzj
Kilo Sage

Use this as a basis


Re: Re: Can you clone/copy a change request?



I would refine that script a little these days by making the noCopy a property so you can edit that value and not he ui action itself.


Can get clever with the tables too if you want


View solution in original post

7 REPLIES 7

poyntzj
Kilo Sage

Use this as a basis


Re: Re: Can you clone/copy a change request?



I would refine that script a little these days by making the noCopy a property so you can edit that value and not he ui action itself.


Can get clever with the tables too if you want


working on it to implement your script.


btw what is the meaning of current.rfc?


couldn't find in the change_request form.


andrew_irwin
Kilo Expert

Julian is correct, use the example he provided changing the change_request to incident. Then just map what fields you want to copy (example {state = current.state;}. I would also suggest you limit this new UI action to a specific role, otherwise it could potentially be miss used. I'm not sure if you actually needing, or wanting an actual record copy, or if your attempting to use the 1st record as a template. If your looking to use the 1st record as a template then there is another way you could achieve this.


If your wanting a template and not a clone then you could create a template for essentially any record, and you can then attach a module as a link to the template. As an example if your Service Desk deals with password resets on a regular basis you can create a template for password resets, where everything is captured on the template other than the caller. So you then add a module link to that password reset template and when your helpdesk gets a call related to password resets they just click on a module named PW Reset (example only) where they only have to provide the caller details and then save the record.


If your just wanting to copy an existing incident and use it as a foundation for a new incident, you can use the UI action below:



find_real_file.png


Determine what kind of UI menu you need or want, for this example I just have it as a button on the top toolbar.



add a condition if you determine you need on:


find_real_file.png


var incident = new GlideRecord("incident");
incident.caller_id = current.caller_id; \\ may opt to remove this or turn off this line
incident.short_description = current.short_description;
incident.cmdb_ci = current.cmdb_ci;
incident.priority = current.priority;
incident.assignment_group = current.assignment_group;
incident.assigned_to = current.assigned_to;
incident.impact = current.impact;
incident.urgency = current.urgency;
incident.category = current.u_category;
incident.subcategory = current.u_subcategory;
incident.description = current.description;
incident.work_notes = current.work_notes.getJournalEntry(-1);
incident.state = 3 ;
parenent_incident = current.sys_id;
var sysID = incident.insert();


current.parent_incident = sysID;


var mySysID = current.update();


gs.addInfoMessage("Incident " + incident.number + " created");
action.setRedirectURL(incident);
action.setReturnURL(current);