Insert a record when you click on New button.

parag_kishor_de
Kilo Explorer

I have a scenario that I want to insert a record in Incident table when click on the 'New' Button   of the Incident list or 'Create New' of incident.

The incident can have only incident number the record must insert as soon as I click and I should not need to save or submit on the incident form.

Please help.

9 REPLIES 9

vinothkumar
Tera Guru

Hi Parag,



Simply try the below script in your UI action



var gr= new GlideRecord('incident');


gr.initialize();


gr.insert();


gs.print(gr.number);


How can you add this above script in this 'New' button   which is next to the incident?Screen Shot 2017-04-06 at 4.03.20 pm.png


Venkateswarlu K
Mega Guru

Hi,


I am trying to create a "copy incident" button that will copy all the completed fields except caller and impacted user to a new incident.   This will be used when we have multiple copies of the same request for different people.   I was able to get te button to display but when I click on it, it doesn't do anything.   Here is my code, any help woul be greatly appreciated.



var newinc = new GlideRecord('incident');


newinc.initialize();
newinc.short_description = current.short_description;
newinc.assignment_group = current.assignment_group;
newinc.assigned_to = current.assigned_to;
newinc.description = current.description;


newinc.short_description = current.short_description;
newinc.impact = current.impact;
newinc.category = current.category;


newinc.state = current.state;
newinc.severity = current.severity;
newinc.priority = current.priority;
newinc.insert();


gs.addInfoMessage('Incident ' + newinc.number + ' created.');
action.setRedirectURL(newinc);
action.setReturnURL(current);


Venkateswarlu K
Mega Guru

HI



may i know the status of ur thread in case if it is resolve then close the thread