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.

Checkbox in Popup Messgae

Jagadish Sanadi
Kilo Sage

Hello All,

 

I have requirement to show Check box value in pop up message.

Right under the message checkbox should come up.

When checkbox value is checked/unchecked it should be saved in User Submitted fields

2 REPLIES 2

Hayo Lubbers
Kilo Sage

Hi,

 

You can have a look at the UI Pages, but this is advanced configuration.

 

Having the checkbox in the HTML field within the g:ui_form. Something like this:

<div><input type="checkbox" id="agreement" name="agreement" value="I agree" onchange="verifyAgreement()">&#160; I have read these conditions and agree</input></div>

<div id="buttons">
	<div style="margin-top:10px; float:right">
		<g:dialog_buttons_ok_cancel ok="return true" cancel="onCancel(); return false;"/>
	</div>
</div>

 

A client script activating / deactivating the OK button

$j( document ).ready(function() {
	$('ok_button').setAttribute('disabled','true');	
});

function verifyAgreement(){
	var agreement = $('agreement').checked;
	if(agreement)
		$('ok_button').removeAttribute("disabled");
	else
		$('ok_button').setAttribute('disabled','true');
}

 

And then you can choose to process it client or serverside (via the processing script). Example of a processing script:

 

processAgreement();

function processAgreement(){
	//Check the agreement checkbox first, if checked, update your 
	var gr = new GlideRecord('<sometable>');
	if(gr.get(currentSysId)){
		gr.setValue('u_agreed', true);
		gr.setValue('state', 2);
		gr.update();
	}
	var urlOnStack = gs.getSession().getUrlOnStack();
	response.sendRedirect(urlOnStack);
}

 

 

Helo Hayo, I am trying checkbox from SpModal. Can it be done?