Cross Scope problem I need some help with Service Portal - Standard Ticket and HR Core

Stephencroc
Kilo Guru

I have a widget that cancels RITMS' and the REQ when someone cancels something from Employee Center.  The widget works fine but there is one small piece that does not work.  The widget has in it to set the sn_hr_core_case to state = 7 (cancelled) but it's not running.  I took the script and ran in it background scripts and am getting the following message:
"

Source descriptor is empty while recording access for table sn_hr_core_case: no thrown error
Security restricted: Read operation on table 'sn_hr_core_case' from scope 'Global' was denied because the source could not be found. Please contact the application admin.
Security restricted: Read operation on table 'sn_hr_core_case' from scope 'Global' was denied. The application 'Global' must declare a cross scope access privilege. Please contact the application admin to update their access requests.

 I have tried to create a cross scope record for this and nothing seems to be working.  
Here is the script I'm using:

var hrCase = new GlideRecord('sn_hr_core_case');
					hrCase.addQuery('sys_id', '1f3c07eefbe9265076d8fc6b4eefdc78'); //this is just for now, it should get the core case from the record that it's on in the employee center but running static for testing
					hrCase.query();
					while (hrCase.next()){
					hrCase.state = '7'; //This should cancel the HR Case 
					hrCase.update(); 
					
					}

Does anyone know how to solve this error, or am I doing something incorrect in the widget?

Thanks

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Stephencroc 

did you try creating Restricted caller access record?

Restricted caller access privilege settings 

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

Utpal Dutta
Tera Guru

Hi Stephen,

Let’s make your code more efficient.

 

1. If you only want to query one record then rather than querying whole table to find a sys_id I suggest you use get() method.

2. Always use getters and setters meaning setValue() and getValue().

3. System automatically defines cross scope privilage when it is not there. You just need to allow it.

 

Your script should look like below:

var hrCase = new GlideRecord('sn_hr_core_case');
hrCase.get('1f3c07eefbe9265076d8fc6b4eefdc78');
hrCase.setValue('state', '7'); //This should cancel the HR Case 
hrCase.update(); 

 

  1. When you will run above script in BG. Open 'sys_store_app' list view.
  2. You will find a record with target name as your HR table. You can also sort with updated and you will get your cross scope privilage record.
  3. Open it and change the status value to 'Allowed' and save the record.
  4. Try running the script again. You shouldn't get any error now.

 

If my answer helps then please mark it Helpful and Correct.

 

Thanks

@Stephencroc If my answer helped then please mark it correct for future references.

 

Thanks

Di Zhang
Tera Guru

1. First check sn_hr_core_case table access settings and make sure it can be read by other applications.

2. Check Restricted Caller Access Privileges to see if there is new request created recently and set the request to allowed