The CreatorCon Call for Content is officially open! Get started here.

cannot access table from a scoped application

kazidon
Giga Contributor

I have a scoped application that I am trying to have access a table in the global application. I have set up the cross scope privileges and I don't have an issue access other tables from Global just that one. Any idea on what might be going on? here are some screen shots to help.

cross scope privilege set up

find_real_file.png

 

user access list on global

find_real_file.png

1 ACCEPTED SOLUTION

To confirm whether you are able to access the custom global table via the scoped app or not. You can follow the below steps.

 

1. Navigate to background-scripts and execute the below script.

var gr = new GlideRecord('u_user_access_list');
gr.addQuery('u_user', 'bdb4e9601341b2006bda75c36144b062');
gr.addQuery('active', true);
gr.query();
while(gr.next())
{

gs.info(gr.getRowCount());

}

 

NOTE: Make sure to select the correct scope before triggering this script.

 

Thanks,

Pradeep Sharma

View solution in original post

6 REPLIES 6

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello,

 

Configuration option looks good to me. Can you share additional details like the script that you are executing to access the table?. Also is this on your personal dev instance?

this is my work dev instance, and here is the script I'm and trying to run

 

function QueryUAT()
{
var gr = new GlideRecord('u_user_access_list');
gr.addQuery('u_user', 'bdb4e9601341b2006bda75c36144b062');
gr.addQuery('active', true);
gr.query();
while(gr.next())
{
uat_software_string += gr.u_service + ',';
uat_software_string_display += gr.u_service.getDisplayValue() + ',';
}

uat_software_array = uat_software_string.split(',');
uat_software_array.length --;

uat_software_array_display = uat_software_string_display.split(',');
uat_software_array_display.length --;
gs.addInfoMessage("Current Software - " + uat_software_array_display.toString());
}

 

output for current software is nothing, when running it from employee history application, when I run it on global I get the output of one application (which is all it should have) of Slack.

kazidon
Giga Contributor

here is the whole script if you need that

 

 

var user = '581949a4136f4b80ce8b7d576144b08d';
var arrayUtil = new global.ArrayUtil();

var uat_software_array = [];
var uat_software_array_display = [];
var new_job_title_software_array = [];
var new_job_title_software_array_display = [];
var add_add_gen_access_array = [];
var remove_add_gen_access_array = [];
var add_add_gen_access_array_display = [];
var remove_add_gen_access_array_display = [];

var new_job_title_software_string = "";
var uat_software_string = "";
var uat_software_string_display = "";
var new_job_title_software_string_display = "";

var counter = 0;

function QueryUAT()
{
var gr = new GlideRecord('u_user_access_list');
gr.addQuery('u_user', 'bdb4e9601341b2006bda75c36144b062');
gr.addQuery('active', true);
gr.query();
while(gr.next())
{
uat_software_string += gr.u_service + ',';
uat_software_string_display += gr.u_service.getDisplayValue() + ',';
}

uat_software_array = uat_software_string.split(',');
uat_software_array.length --;

uat_software_array_display = uat_software_string_display.split(',');
uat_software_array_display.length --;
gs.addInfoMessage("Current Software - " + uat_software_array_display.toString());
}


function QueryNewJobTitle()
{
var gr = new GlideRecord('x_prole_emp_onb_employee_onboarding');
gr.addQuery('u_job_title', 'e9885e5113268bc08242335fd144b0f7');
gr.addQuery('u_list_location', 'Draper Headquarters');
gr.query();
while(gr.next())
{
new_job_title_software_string += gr.u_add_gen_access + ',';
new_job_title_software_string_display += gr.u_add_gen_access.getDisplayValue() + ',';
}
new_job_title_software_array = new_job_title_software_string.split(',');
new_job_title_software_array.length --;

new_job_title_software_array_display = new_job_title_software_string_display.split(',');
new_job_title_software_array_display.length --;
gs.addInfoMessage("New Software - " + new_job_title_software_array_display.toString());
}

function ArrayDiff()
{
add_add_gen_access_array = arrayUtil.diff(new_job_title_software_array, uat_software_array);
add_add_gen_access_array_display = arrayUtil.diff(new_job_title_software_array_display, uat_software_array_display);

remove_add_gen_access_array = arrayUtil.diff(uat_software_array, new_job_title_software_array);
remove_add_gen_access_array_display = arrayUtil.diff(uat_software_array_display, new_job_title_software_array_display);
gs.addInfoMessage("Add This - " + add_add_gen_access_array_display.toString());
gs.addInfoMessage("Remove This - " + remove_add_gen_access_array_display.toString());
gs.addInfoMessage('Remove Length - ' + remove_add_gen_access_array.length);
}

QueryUAT();
QueryNewJobTitle();
ArrayDiff();

To confirm whether you are able to access the custom global table via the scoped app or not. You can follow the below steps.

 

1. Navigate to background-scripts and execute the below script.

var gr = new GlideRecord('u_user_access_list');
gr.addQuery('u_user', 'bdb4e9601341b2006bda75c36144b062');
gr.addQuery('active', true);
gr.query();
while(gr.next())
{

gs.info(gr.getRowCount());

}

 

NOTE: Make sure to select the correct scope before triggering this script.

 

Thanks,

Pradeep Sharma