Java Script help

dpa20
Tera Contributor

I have a catalog " Application installation request" It has 2 variables computer name and application name. Both type are reference cmdb_ci_computer and cmdb_ci_spkg respectively. I need help writing catalog client script please.

Example:

User is requesting for Computer 1 to have Adobe Acrobat 5.0 but on the Adobe Acrobat 5.0 record (cmdb_ci_spkg) Computer 1 is already there on the "installed on". I need help in writing script so that ServiceNow would not accept that request saying that computer 1 already have that Adobe Acrobat 5.0.

 

dpa20_0-1723227394658.png

 

1 REPLY 1

Brian Lancaster
Tera Sage

OnSubmit client script. If you think you will have a lot of catalog items were you might need to do this you can move most of this code to a client callable script include.

function onSubmit() {
    //Type appropriate comment here, and begin script below
    var gr = new GlideRecord('cmdb_software_instance');
    gr.addQuery('installed_on', current.variables.computer_variable);
    gr.addQuery('software', current.variables.software_variable);
    gr.query();
    if (gr.next()) {
        gs.addInfoMessage("This computer " + current.variables.computer_variable.getDisplayValue() + " already has " + current.variables.software_variable + " installed.");
		return false;
    }
}