Create a UI action to create incident in workspace

Rakshanda Kunte
Tera Contributor

How to create a UI Action in workspace to create an incident from an alert.

Can anyone help with Workspace client script?

 

Thanks.

3 REPLIES 3

Ethan Davies
Mega Sage
Mega Sage

Hey Rakshanda,

 

You can use the 'Create Incident' UI Action that comes OOTB for the Interaction Table as a foundation for your UI Action, you can find it on your instance by visiting the following URL:

 

https://INSTANCE_NAME/now/nav/ui/classic/params/target/sys_ui_action.do%3Fsys_id%3Da89d504b873303002...

 

Here is a sample of the script here:

var canCreateIncident = false;
if ((current.isNewRecord() && current.canCreate()) || (!current.isNewRecord() && current.canWrite()))
	canCreateIncident = current.update();
else
	canCreateIncident = true;

if (canCreateIncident) {
	var inc = new GlideRecord("incident");
	inc.initialize();
	inc.caller_id = current.opened_for;
	inc.short_description = current.short_description;
	if (gs.getProperty("com.snc.incident.create_from_interaction.save") === 'true') {
		inc.work_notes = gs.getMessage('Incident created from Interaction {0}', current.number);
		var incSysId = inc.insert();
		if (incSysId) {
			var interactionRelatedGR = new GlideRecord("interaction_related_record");
			interactionRelatedGR.initialize();
			interactionRelatedGR.interaction = current.sys_id;
			interactionRelatedGR.document_table = 'incident';
			interactionRelatedGR.document_id = incSysId;
			interactionRelatedGR.insert();
		}
	}
	action.openGlideRecord(inc);
	new InteractionRelationshipUtil().copyAttachments(current, inc);
}

 

This is fine. But it is automatically creating an incident. 
I want to get to 'Create New Incident' page, so that unless the agent clicks on save, the record won't get created.

Did you get the "Create incident" from interaction on workspaces to open the 'Create New Incident' page?  If so, how?