How to make script include as publicly callable and accessible.

Hrishabh Kumar
Giga Guru

I have a client callable script include, but only users with admin role are able to access the script include.

I want to make it public so that no roles or minimal role is require to access the script include.

 

Here is my script include:

SIpublic.PNG

 

function getUserArray() {
    var currentUser = gs.getUserID();
    var assignees_one = [];
    var user = new GlideRecord("sys_user");
    user.addQuery('manager', currentUser);
    user.query();
//     gs.log("total is: " + user.getRowCount());
    while (user.next()) {
        // 	gs.log("sys_id: "+ user.getUniqueValue());
        assignees_one.push(user.getUniqueValue());
    }
    var assignees_two = [];
    for (var i = 0; i < assignees_one.length; i++) {
        // 	gs.log("run "+ i + " id: " + assignees_one[i]);
        var user_1 = new GlideRecord('sys_user');
        user_1.addQuery('manager', assignees_one[i]);
        user_1.query();
        // 	gs.log("result for "+ i + " : " + user_1.getRowCount());
        while (user_1.next()) {
            assignees_two.push(user_1.getUniqueValue());
        }
    }
	
    var assignees_three = [];
    for (var j = 0; j < assignees_two.length; j++) {
        // 	gs.log("run "+ j + " id: " + assignees_two[j]);
        var user_2 = new GlideRecord('sys_user');
        user_2.addQuery('manager', assignees_two[j]);
        user_2.query();
        // 	gs.log("result for j : "+ j + " : " + user_2.getRowCount());
        while (user_2.next()) {
            assignees_three.push(user_2.getUniqueValue());
        }
    }
	
    var assignees_total = assignees_one.concat(assignees_two).concat(assignees_three);
	assignees_total.push(currentUser);
    gs.log("SI total lentgh: " + assignees_total.length);
    gs.log("SI one : " + assignees_one.length);
    gs.log("SI two : " + assignees_two.length);
    gs.log("SI three : " + assignees_three.length);

    var groups_total = [];
    for (var k = 0; k < assignees_total.length; k++) {
        var getGroup = new GlideRecord("sys_user_grmember");
        getGroup.addQuery("user", assignees_total[k]);
        getGroup.query();
        gs.log(getGroup.getRowCount());
        while (getGroup.next()) {
            groups_total.push(getGroup.group.name);
            gs.log("sys k: " + k + " sys_id: " + getGroup.getUniqueValue() + " name : " + getGroup.group.name);
        }
    }
	
	var final_group = [];
    for (var l = 0; l < groups_total.length; l++) {
        var sys_group = new GlideRecord("sys_user_group");
        sys_group.addQuery('name', groups_total[l]);
        sys_group.query();
        while (sys_group.next()) {
            final_group.push(sys_group.getUniqueValue());
            gs.log("sysid: " + sys_group.getUniqueValue() + " name: " + sys_group.name);
        }
    }
    return final_group;
}
3 REPLIES 3

Karan Chhabra6
Mega Sage
Mega Sage

Hi @Hrishabh Kumar ,

 

Please check if there are any ACL's defined for this script include, elevate to a security admin role and then navigate to ACL list. Check for any ACL's of type client_callable_script_include, operation would be read in your case

KaranChhabra6_0-1684233595880.png

 

Change the roles accrodingly

KaranChhabra6_1-1684233667364.png

 

If my answer has helped with your question, please mark it as correct and helpful

 

Thanks!

I found a same client_callable_script_include for getUserArray, I triend removing the role and saving it, and even deactivated the ACL but still it is not working.

 

Prince Arora
Tera Sage
Tera Sage

@Hrishabh Kumar 

 

Can you please add below snippet in your script include and try again:

 

  isPublic: function() {

    return true;

  },

 

Please find more info HERE 

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.