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

It was however we are no longer using this as Copy Incident is now available OOB.

Thanks Brain, For this OOB Copy Incidnet. It is copying whole data from old to new incident. How to pass only few field which needed ?

Thanks

Balaji Prusty

I believe there is a way to override the script include that is used.  You may be better off creating your own question.  What I cam up with was a temporary workaround that did not work very well.  It was only needed until we upgraded to a version that had the copy incident.