Not needed

cicgordy
Tera Guru

Deleted

1 REPLY 1

Gustav Aldenbra
Kilo Sage

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
    }
});
}