Dynamic filter is not working when using system property in script include

varanyas024
Tera Contributor

Dynamic filter is not working when using system property in script include

Code:

var MembersOfStoreGHD = Class.create();
MembersOfStoreGHD.prototype = {

    getGroupMembers: function() {

        var strId = '';
        var groups = gs.getProperty('store.ghd.groups');

        var gr = new GlideRecord('sys_user_grmember');
        gr.addQuery('group', 'IN', groups);
        gr.query();

        while (gr.next()) {

            var userId = gr.getValue('user');

            if (strId.indexOf(userId) == -1) {
                strId += userId + ',';
            }
        }

        gs.info('Dynamic Filter Return Ids => ' + strId);

        return strId;
    },

    type: 'MembersOfStoreGHD'
};

And I have created the dynamic filter correctly.
Please suggest something because I have been restricted to use the sys id directly in code.
 
2 REPLIES 2

Kieran Anson
Kilo Patron

Dynamic filters run in the script sandbox which disables access to certain capabilities, these are documented below 

 

https://www.servicenow.com/docs/r/api-reference/scripts/script-sandbox.html 

What should I do then?