How to make script include as publicly callable and accessible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 03:18 AM
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:
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 03:41 AM
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
Change the roles accrodingly
If my answer has helped with your question, please mark it as correct and helpful
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 04:57 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 04:00 AM
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.