Make checkbox true based on another form's field value
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2022 06:43 AM
Hi. I want to make a checkbox "check" true on the incident task form if the category of the incident is "Env" on the incident form.
If someone could help me how can I set a checkbox true based on another form's value.
5 REPLIES 5

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2022 12:06 AM
Hi Savvy,
Create a onChange() script on field "Incident" on table "Incident Task" that calls Script Include to check incident's category.
1. onChange() client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var catName = 'Env';
var ajax = new GlideAjax('IncidentUtilClient');
ajax.addParam('sysparm_name', 'checkCategory');
ajax.addParam('sysparm_incident_id', newValue);
ajax.addParam('sysparm_cat_name', catName);
ajax.getXMLAnswer(function(answer) {
alert(answer);
if (answer.length > 0) {
if (answer == 'true') {
g_form.setValue('<field to check>', true);
} else {
g_form.setValue('<field to check>', false);
}
}
});
}
Script Include
var IncidentUtilClient = Class.create();
IncidentUtilClient.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkCategory: function() {
var incidentId = this.getParameter('sysparm_incident_id');
var categoryName = this.getParameter('sysparm_cat_name');
var grIncident = new GlideRecord('incident');
grIncident.addQuery('sys_id', incidentId);
grIncident.addQuery('category', categoryName);
grIncident.query();
if (grIncident.hasNext()) {
return "true";
}
return "false";
},
type: 'IncidentUtilClient'
});