Using Script Includes in Domain Separated Environment

asd13
ServiceNow Employee
ServiceNow Employee

I'm working on a domain separated instance and am using client scripts to configure forms based on what company is selected.   I'm using an ajax script include which includes queries across the core_company table (including companies outside the users assigned domain).   Doing some testing as users within different domains it appears the SI company queries are being restricted to the logged in user's own domain visibility.

I was assuming the SI wouldn't restrict as it's non domain aware and it's essentially a library call, abstracted from the user session.

Has anyone come across this before and is there a way to force the SI function to run globally in scope?

thanks
David

1 ACCEPTED SOLUTION

The SN Nerd
Giga Sage
Giga Sage

As someone who has helped build and support a domain separated system, I can tell you that this is expected behavior.


If you want your script include to ignore domain separation when querying tables you need to use the code below.



var rec =new GlideRecord('incident');


rec.queryNoDomain();


while (rec.next()) {


gs.print(rec.number + ' exists');


}



I hope this helps



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

View solution in original post

3 REPLIES 3

Deepak Ingale1
Mega Sage

Hello David,


I think that is a normal behavior.


Your data visibility is restricted to user's domain and to the domain he has visibility to.


So data returned by your script include will only include companies to which user has visibility


The SN Nerd
Giga Sage
Giga Sage

As someone who has helped build and support a domain separated system, I can tell you that this is expected behavior.


If you want your script include to ignore domain separation when querying tables you need to use the code below.



var rec =new GlideRecord('incident');


rec.queryNoDomain();


while (rec.next()) {


gs.print(rec.number + ' exists');


}



I hope this helps



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

asd13
ServiceNow Employee
ServiceNow Employee

Thanks Paul - exactly what I was after - cheers!