Conformation message

Anusha Medharam
Tera Contributor

whenever i am trying to create the case that any open cases on same category and service id that time I need one conformation mail with YES or NO buttons. Whenever I click yes button case will be created , click on NO the system should not permit the creation of a new case.

 

 

1797.JPG

1 REPLY 1

tharun_kumar_m
Mega Guru

Hi Anusha,

 

You can do that by following the below scripts.

 

The below script will Popup a confirm box while submitting the incident. The pop up appears only if there is at least one active incident with same business service.

The Popup contains list of incidents with same business service and the message you specified.

Only If no business service is entered in the form or users clicks "Yes" during popup, the incident will get created.

 

Script include - Name: checkIncidentExist

var checkIncidentExist = Class.create();
checkIncidentExist.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	checkServiceExists: function() {
		var businessService = this.getParameter('businessService'); //value from client script
		var incidents = "";
		var gr = new GlideRecord('incident');
		gr.addQuery('business_service', businessService);
		gr.addQuery('active',true);
		gr.query();
		
		while(gr.next()){
			incidents+=gr.number+" ";
		}
		return incidents;
			
    },
    type: 'checkIncidentExist'
});

Client script - Type: onSubmit

function onSubmit(){
	
	var businessService = g_form.getValue('business_service');
	
	if(businessService!=""){ //if business_service is not filled, the incident will be created

	//call script include
	var ga = new GlideAjax('checkIncidentExist');
	ga.addParam('sysparm_name','checkServiceExists');
	ga.addParam('businessService',businessService);
	ga.getXMLWait();
	var incidentNumber = ga.getAnswer();
	
	if(incidentNumber){
		if(confirm("Open case "+incidentNumber+" exist for the same Service ID and Category. Do you still wish to proceed with creating a new case?")){
			return true;
		}
		else
			return false;
	}
	}
}

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumbs up.

 

Best regards,

Tharun Kumar