We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Class functions from script include are not getting called in Lab platform

saradaa
Kilo Contributor

I copied code from labs exactly and did multiple labs, but could never get a call to class function working in lab instance. If I change it to function code only , it works. Below is a snippet of code.

 

Now able to call class function in business rule and client script. I have made sure that I copy code exactly from the lab work.

 

Script:

-------

var AssignmentGroupUtils = Class.create();
AssignmentGroupUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    countGroupMembers: function() {

        var grpName = "";
        var message = "There are no members in this Assignment Group";
        var groupID = this.getParameter('sysparm_group_id');

        var grpMems = new GlideRecord('sys_user_grmember');
        grpMems.addQuery('group.sys_id', groupID);
        grpMems.query();

        if (grpMems.next()) {
            grpName = grpMems.getDisplayValue('group');
        } //close if

        if (grpName != "") {
            message = "There are " + grpMems.getRowCount() + " members in the " + grpName + " group";
        } //close if

        return message;

    },

    type: 'AssignmentGroupUtils'
});

0 REPLIES 0