UI Action copy incident

Brian Lancaster
Tera Sage

I have a requirement to copy and but I do not want to insert the record right away.  Instead I want it to copy some of the fields to the new incident but I need to leave some mandatory fields blank.  So I would like it to act like someone click create new incident but the only difference is that things like short description, description, etc get copied to the new incident.

1 ACCEPTED SOLUTION

Brian Lancaster
Tera Sage

I found this GURU article I'm trying to follow it.  I put in some alert and found that it is calling the function in the client script seems to die after the first line in the function getParamVal.  Below is my code to for the UI action and client script.

UI Acation:

createRecord();
function createRecord(){
	var shortdesc = current.getValue('short_description');
	var desc = current.getValue('description');
	var imp = current.getValue('impact');
	var urg = current.getValue('urgency');
	var ci = current.getValue('cmdb_ci');
	var url = 'incident.do' + '?sysparm_shortdescription='+shortdesc+'&sysparm_description='+desc+'&sysparm_impact='+imp+
		'&sysparm_urgency='+urg+'&sysparm_cmdbci='+ci;
	action.setRedirectURL(url);
}

Client Script:

function onLoad() {
	//Populate the variables with the parameters passed in the URL
	//Use the 'getParmVal' function below to get the parameter values from the URL
	
	var shortdesc = getParmVal('sysparm_shortdescription');
	var desc = getParmVal('sysparm_description');
	var imp = getParmVal('sysparm_impact');
	var urg = getParmVal ('sysparm_urgency');
	var ci = getParmVal('sysparm_cmdbci');
	
	g_form.setValue('short_description', shortdesc);
	g_form.setValue('description', desc);
	g_form.setValue('impact', imp);
	g_form.setValue('urgency', urg);
	g_form.setValue('cmdb_ci', ci);
}

function getParmVal(name){
	var url = document.URL.parseQuery();
	if(url[name]){
		return decodeURI(url[name]);
	}
	else{
		return;
	}
}

View solution in original post

12 REPLIES 12

sachin_namjoshi
Kilo Patron
Kilo Patron

Please see answer below

 

https://community.servicenow.com/community?id=community_question&sys_id=9eb1fa37dba89f08852c7a9e0f96198f

 

Regards,

Sachin

Can I pass stuff like short description, description, sys_id to be put in the parent incident filed via sysparms?

Yes, you can definitely do that.

 

var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
var dialog = new dialogClass('update_resource_capacity');
dialog.setTitle(new GwtMessage().getMessage("Select Date Range"));
dialog.setPreference('sysparm_description', new GwtMessage().getMessage('This action will update capacity of the group used for resource reports in the following tables - Resource Aggregates Daily, Resource Aggregates Weekly and Resource Aggregates Monthly.'));
dialog.setPreference('sysparm_resource_id', sysId);
dialog.setPreference('sysparm_resource_type', 'group');
dialog.setWidth(430);
dialog.render();

Regards,

Sachin

 

 

I'm not following what you code is doing.