Alert Message

satyamc
Tera Expert

Hi All, 

There is one task that the table name 'Exception' in  that table i created one list field named as VITs and it refer to the another table name 'sn_vul_vulnerable_item' in that table form i created one choice field named as Reopened and the value is True/False just like a checkbox if the value is True in a particular record then if  i selected in the exception table so it passed the alert message that "vulnerable number + reopen is True "or if i select multiple record then also shows the alert mgs to all the record if the value is true.  

 

Please suggest how to implement this . Any help is appreciated,

 

Thanks in advance.

1 ACCEPTED SOLUTION

satyamc
Tera Expert

script include 

 

var CheckReopenList = Class.create();
CheckReopenList.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
    checkReopenList: function() {
        var ciSysIds = this.getParameter('sysparm_ci_sysids');
        var ciArray = ciSysIds.split(',');
        var messages = [];

 

        for (var i = 0; i < ciArray.length; i++) {
            var ciSysId = ciArray[i];
            var vi = new GlideRecord('sn_vul_vulnerable_item'); // Changed table

 

            gs.log('CIReopenListUtil: checkReopenList called with sys_ids: ' + ciSysIds, 'MyScript');

 

            if (vi.get(ciSysId)) {
                gs.log('CIReopenListUtil: Found Vulnerable Item: ' + vi.number, 'MyScript');

 

                if (vi.reopened == true) { // Make sure this field exists on the table.
                    gs.log('CIReopenListUtil: ' + vi.number + ' reopen is true', 'MyScript');
                    messages.push(vi.number + " is reopened is true"); //changed the message.
                }
            }
        }
        return JSON.stringify(messages);
    },
    type: 'CheckReopenList'
});

 

client script 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var ciSysIds = newValue;
    var ga = new GlideAjax('CheckReopenList');
    ga.addParam('sysparm_name', 'checkReopenList');
    ga.addParam('sysparm_ci_sysids', ciSysIds);
    ga.getXMLAnswer(function(answer) {
        var messages = JSON.parse(answer);
        if (messages.length > 0) {
            alert(messages.join('\n'));
        }
    });
}

 this worked in my PDI but isn't working in the Dev instance

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@satyamc 

so what script did you try so far and what didn't work

what debugging did you perform?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

satyamc
Tera Expert

script include 

 

var CheckReopenList = Class.create();
CheckReopenList.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
    checkReopenList: function() {
        var ciSysIds = this.getParameter('sysparm_ci_sysids');
        var ciArray = ciSysIds.split(',');
        var messages = [];

 

        for (var i = 0; i < ciArray.length; i++) {
            var ciSysId = ciArray[i];
            var vi = new GlideRecord('sn_vul_vulnerable_item'); // Changed table

 

            gs.log('CIReopenListUtil: checkReopenList called with sys_ids: ' + ciSysIds, 'MyScript');

 

            if (vi.get(ciSysId)) {
                gs.log('CIReopenListUtil: Found Vulnerable Item: ' + vi.number, 'MyScript');

 

                if (vi.reopened == true) { // Make sure this field exists on the table.
                    gs.log('CIReopenListUtil: ' + vi.number + ' reopen is true', 'MyScript');
                    messages.push(vi.number + " is reopened is true"); //changed the message.
                }
            }
        }
        return JSON.stringify(messages);
    },
    type: 'CheckReopenList'
});

 

client script 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var ciSysIds = newValue;
    var ga = new GlideAjax('CheckReopenList');
    ga.addParam('sysparm_name', 'checkReopenList');
    ga.addParam('sysparm_ci_sysids', ciSysIds);
    ga.getXMLAnswer(function(answer) {
        var messages = JSON.parse(answer);
        if (messages.length > 0) {
            alert(messages.join('\n'));
        }
    });
}

 this worked in my PDI but isn't working in the Dev instance