Calling Script include in reference qualifier

anmolvishwa
Tera Contributor

Hello everyone,

i am not able to see the see the user which i set in script include.

Can anyone help ?

 

Script include :

Name : CZTest

API Name : global.CZTest

Code : 

var CZTest = Class.create();
CZTest.prototype = Object.extendsObject(AbstractAjaxProcessor, {
   
    getValidUsers: function() {
        var array = ["62826bf03710200044e0bfc8bcbe5df1", "5408091a3b100300e81d47b334efc452"];
        return array;
    },

    type: 'CZTest'
}); 
 
Reference Qualifier : javascript:new CZTest().getValidUsers();
5 REPLIES 5

GopikaP
Mega Sage

Hi @anmolvishwa , 

Can you return the array as a comma-separated string value: 

 

getValidUsers: function() {
        var array = ["62826bf03710200044e0bfc8bcbe5df1", "5408091a3b100300e81d47b334efc452"];
        return 'sys_idIN'+array.toString();
    },

 

Also, add the 'sys_idIN' while returning the string or you can add the same in the reference qualifier also - 

javascript: 'sys_idIN'+new CZTest().getValidUsers()';

J Siva
Tera Sage

Hi Anmol,

The script is returning the array of sys ids, which is not ideal.

 

Format of simple ref qualifier: sys_idIN<user1sys id>,<user2sys_id>;

So the script should return the output like above.

Eg: return 'sys_idIN62826bf03710200044e0bfc8bcbe5df1,5408091a3b100300e81d47b334efc452';

Please update the script and let me know how it goes.

 

Regards,

Siva

JenniferRah
Mega Sage

Is the script include Client Callable? 

 

Does the user running it have the role necessary in the script include's ACL?

 

If all that is correct, change your reference qualifier to this: 

javascript&colon;var ids = new CZTest().getValidUsers(); "sys_idIN" + ids.join(', ').toString();

 

Ankur Bawiskar
Tera Patron
Tera Patron

@anmolvishwa 

this will work in advanced ref qualifier

javascript&colon; 'sys_idIN' + new CZTest().getValidUsers().toString();

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