Not needed
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 03:05 AM - edited ‎02-22-2024 05:11 AM
Deleted
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 03:31 AM
Hi @cicgordy
You would need to call a script include form your client script. You could do something like the code below
Script include (client callable):
var CheckEquipmentRequirement = Class.create();
CheckEquipmentRequirement.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isMoreEquipmentRequired: function() {
var hardwareSysId = this.getParameter('sysparm_hardware_sysid');
var hardwareGR = new GlideRecord('alm_hardware');
if (hardwareGR.get(hardwareSysId)) {
return hardwareGR.getValue('more_equipment_required');
}
return 'false'; // Return 'false' as a string if not found
}
});
Client Script (onchange):
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('CheckEquipmentRequirement');
ga.addParam('sysparm_name', 'isMoreEquipmentRequired');
ga.addParam('sysparm_hardware_sysid', newValue);
ga.getXMLAnswer(function(answer) {
var displayField = 'add_more_details';
if (answer == 'true') {
g_form.setVisible(displayField, true);
} else {
//If you want to do something else if anawer is false
}
});
}