How to add a Checkbox in spModal() script

Lavanya Nagendr
Giga Guru

Hi Everyone,

 

I have a client script that opens spModal() window when the state of the record is changed. Now i need to include a checkbox message to the script,but couldnt achieve this with 'checkbox' attribute. The second function() for the "Evidence not Required" button is not working also. Kindly help on this.

 

Client Script:

OnChange of State

 

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}
	var ajax = new GlideAjax('SP_AuditUtils');
	ajax.addParam('sysparm_name', 'getFieldValues');
	ajax.addParam('sysparm_id', g_form.getUniqueValue());
	ajax.addParam('sysparm_table', g_form.getTableName());
	ajax.addParam('sysparm_fields', 'state');
	ajax.getXMLAnswer(function(answer) {
		answer = JSON.parse(answer);

		if (g_form.getValue('state') == 'closed' && answer.state != 'closed') {
			//if(newValue == 'free') return;

			spModal.open({
				"title": "Auditor Evidence Confirmation",
				"message": "Have you attached an email which confirms that you can close this Finding?",
				"checkbox":"I hereby confirm this Finding can be closed and evidence has been attached",
				"buttons": [{
					label: "✔ Confirm",
					primary: true
				},
							{
								label: "Evidence not Required",
								simple: true
							},
							{
								label: "✘ Close",
								cancel: true
							}
						   ],
				"backdrop": "static",
				"keyboard": false
			}).then(function() {
				g_form.setValue('comments', 'I hereby confirm this finding can be closed and evidence has been attached');
				g_form.save();
			},
					function() {
				g_form.setValue('comments', 'Evidence is not needed to close this Finding');
			},
					function() {
				g_form.setValue('u_substate', '');
			});

		}
	});
}

 

 

Thanks,

Lavanya

1 REPLY 1

Paul Curwen
Giga Sage

According to the latest documentation 'checkbox' is not a supported object for spModal:

 

https://docs.servicenow.com/en-US/bundle/vancouver-api-reference/page/app-store/dev_portal/API_refer...

 

https://developer.servicenow.com/dev.do#!/reference/api/vancouver/client/SPModal-API#SPM-confirm_S

 

If helpful please mark as Helpful/Correct

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul