Incident for Record Producer

Elton Batista
Tera Contributor

Hi Guys,

 

i have a problem, i need creat incident equal the user reques Service Portal more I am unable.

 

any know how i can make?

 

with UI Action i open incident, more not with variables record producer.

 

 

Workspace Client Script:

function onClick(g_form) {

		var recordDetails = {
		caller_id: g_form.getValue('caller_id'),
		description: g_form.getValue('description'),
		requested_for: g_form.getValue('u_requested_for'),
		employee_number: g_form.getValue('employee_number'),
		email: g_form.getValue('email'),
		vs_immediate_superior: g_form.getValue('vs_immediate_superior'),
		store: g_form.getValue('store'),
		cost_center: g_form.getValue('cost_center'),
		reason_of_solicitation: g_form.getValue('reason_of_solicitation')
		
	};
	
	var dados = JSON.stringify(recordDetails);
	alert(dados);
	var ga = new GlideAjax('global.IncidentUtil');
	ga.addParam('sysparm_name', 'createIncident');
	ga.addParam('sysparm_recordDetails', JSON.stringify(recordDetails));
	ga.getXMLAnswer(openIncRecord);
	
	function openIncRecord(answer) {
		if (answer) {
			
			
			//g_navigation.open(answer, '_blank');
			g_form.setValue('comments', "SEU CHAMADO é " + answer);
			saveChange();
			
			
		}
		else {
			g_form.addErrorMessage("There was an issue");
		}
	}
	
function saveChange() {
    g_form.save();
    action.setRedirectURL(current);
}
}

 Script Include:

var IncidentUtil = Class.create();
IncidentUtil.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
	
		createIncident: function() {
		try {
			
			var recDetails = JSON.parse(this.getParameter('sysparm_recordDetails'));
			var incGr = new GlideRecord('incident');
			incGr.newRecord();
			incGr.setValue('caller_id', recDetails.requested_for);
			incGr.setValue('category', gs.getProperty('category_frente_caixa_incident',''));
			incGr.setValue('subcategory', gs.getProperty('catalog_item_erroPreco',''));
			incGr.setValue('service_offering', gs.getProperty('service_offering_erroPreco',''));
			incGr.setValue('impact', 1);
			incGr.setValue('urgency', 2);
			incGr.setValue('priority', 2);
			incGr.setValue('assignment_group', gs.getProperty('x_asat_csc.assignmentgroup.ti_automacao_servicenow',''));
			incGr.setValue('short_description', "Frente de Caixa - Erro de preço - Preço errado");
			incGr.setValue('description', recDetails.description);
			incGr.setValue('requested_for', recDetails.requested_for);
			incGr.setValue('employee_number', recDetails.employee_number);
			incGr.setValue('email', recDetails.description);
			incGr.setValue('vs_immediate_superior', recDetails.description);
			incGr.setValue('store', recDetails.store);
			incGr.setValue('cost_center', recDetails.cost_center);
			incGr.setValue('phone', recDetails.phone);
			incGr.setValue('information_store', recDetails.store);
			incGr.setValue('how_many_pdvs', "all");
			incGr.setValue('reason_of_solicitation', "rebaixa_preco_promocional");
			var incSysID = incGr.insert();
			var incNumber = incGr.number;

			return incNumber;
			//return "/incident.do?sys_id=" + incSysID;
			
		}
		catch(ex) {
			gs.error("Incident creation error : " + ex);
			return null;
		}
	},

    type: 'IncidentUtil'
});
0 REPLIES 0