Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Custom popup box in Agent Workspace

Khalnayak
Kilo Sage

Hi Guys,

I have a client script for UI16 which displays a popup box to confirm an action.

I am using Glidemodal  for this and this works fine.

However, this doesnt work in Agent Workspace, so how can I create a custom modal popup in Agent Workspace that allows me to display a message with a a yes and no, and if yes trigger the rest of the script.
Thanks.

 

1 ACCEPTED SOLUTION

Pranesh072
Mega Sage

try g_modal.confirm in workspace client script 

 

var msg = getMessage("Are you sure you want to end this chat?");
	g_modal.confirm(getMessage("Confirmation"), msg, function (confirmed) {
		if (confirmed) {
			g_form.setValue('state', 'closed_complete');
			g_form.save();
		}
	});
	
	return false;

 

find_real_file.png

View solution in original post

8 REPLIES 8

function onClick() {

//Set the 'Incident state' and 'State' values to 'Resolved', and display mandatory fields
g_form.setValue('incident_state', 6);
g_form.setValue('state', 6);
g_form.setValue('resolved_by', g_user.userID, g_user.getFullName());

var close_code = g_form.getValue("close_code");
var close_notes = g_form.getValue("close_notes");

var opentasks = '';
var ga_1 = new GlideAjax('IncidentTaskUtilsAjax');
ga_1.addParam('sysparm_name', 'openTasksAvailable');
ga_1.addParam('sysparm_incident', g_form.getUniqueValue());
ga_1.getXML(function(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
opentasks = answer;
if ((opentasks == "Yes") && (close_code != '') && (close_notes != '')) {
g_modal.confirm("Warning", "You are about to resolve an Incident with open incident tasks",function(ret) {
if(ret)
{
g_form.submit('resolve_incident');
}
});

}
});

}

make sure you are writing it in workspace client script.

 

try following code 

 

function onClick(g_form) {

	//Set the 'Incident state' and 'State' values to 'Resolved', and display mandatory fields
	g_form.setValue('incident_state', 6);
	g_form.setValue('state', 6);
	g_form.setValue('resolved_by', g_user.userID, g_user.getFullName());

	var close_code = g_form.getValue("close_code");
	var close_notes = g_form.getValue("close_notes");

	var opentasks = '';
	var ga_1 = new GlideAjax('IncidentTaskUtilsAjax');
	ga_1.addParam('sysparm_name', 'openTasksAvailable');
	ga_1.addParam('sysparm_incident', g_form.getUniqueValue());
	ga_1.getXML(function(response) {
		var answer = response.responseXML.documentElement.getAttribute("answer");
		opentasks = answer;
		if ((opentasks == "Yes") && (close_code != '') && (close_notes != '')) {
			g_modal.confirm("Warning", "You are about to resolve an Incident with open incident tasks",function(ret) {
				if(ret)
				{
					g_form.submit('resolve_incident');
				}
			});

		}
	});
	return false;
}

Hi Pranesh

What is the reason for 'return false' at the end of the code in work space client script.

But how to get a same kind popup in workspace with our own options instead ok and cancel. 

Again if I have written any function on click of cancel that also works when i close popup using cross mark.? how to avoid it? 

 

my requirement is I need to show popup with my own options and options have individual functionality and if i want to close window i can use cross so that nothing will happen we be remains where we are page.