Read operation on table 'sn_hr_core_case_talent_management' from scope 'Global' was denied. The appl

poornima batchu
Tera Expert

Hi All, 

 

I have executed this below script in the Background scripts.

 

 

 

var sysid = '2963551097ef1990968dfee3a253af1a';
var gr = new GlideRecord('sys_audit');
gr.addEncodedQuery('tablename=sn_hr_core_case_talent_management^fieldname=state^oldvalue=24^ORnewvalue=24^documentkey='+sysid);
gr.orderByDesc('sys_created_on');
gr.query();
var c = 0;
var sec = 0;
while (gr.next()) {
    if (c % 2 == 0) {
        now = new GlideDateTime(gr.sys_created_on);
        gs.info('poonam now' + now);
    } else {
        pre = new GlideDateTime(gr.sys_created_on);
        gs.info('poonam pre' +pre);
        var workTime = gs.dateDiff(pre, now, true);
        sec += parseInt(workTime);
        gs.info('poonam duration' +workTime);
    }
    c += 1;
}
gs.info('poonam sec' +sec);
var workDate = new Date(sec * 1000).toISOString();
var workDateString = workDate.substring(0, 19);
gs.info('poonam workdate' +workDateString);
var gr1 = new GlideRecord('sn_hr_core_case_talent_management');
gr1.addQuery('sys_id',sysid);
gr1.query();
if(gr1.next()){
    gr1.setValue('u_hr_suspended_duration',workDateString);
    gr1.update();
}

 

 

 

I got the output correct but the data is not updated in the given field and it shows this below error. I have allowed the RCAP errors and also created cross scope previllages

poornimabatchu_0-1723648019846.png

poornimabatchu_1-1723648193019.png

poornimabatchu_2-1723648226015.png

 

Can anyone please let me know what's the issue.

 

The actual requirement is -- I need the duration of the hr state choice "suspended" ( I would like to see for each HR case how long the ticket was in the suspended state and this is for the all active and Inactive cases. I have enabled the Field value duration for this table recently. As it not having the old cases data, I have written this Background script to calculate the state choice duration 

 

 

 

 

 

 

4 REPLIES 4

Sandeep Rajput
Tera Patron
Tera Patron

@poornima batchu There are two ways to address this issue.

1. Create a fix script in the HR Core scope and execute your script through it.

OR

2. Update your RCAP records and choose the Source Scope as Global and Target Scope as Human Resource Core for both Read and Write operations.

 

Hope this helps.

Slava Savitsky
Giga Sage

The error message clearly indicates that the operation is not allowed by cross-scope privileges. In your screenshots, Global is selected as the target scope, but if I understand correctly, you are running a script in Global to update HR cases, which means Global is the source scope.

 

Initially, I have tried Global in Source scope but it says invalid insert

poornimabatchu_0-1723702665509.png

 

 

@poornima batchu You tried to create a record in Global scope which is incorrect. Create the same record in Human Resource Core scope with following values populated.

1. Source Scope: Global

2, Target Scope: Human Resource Core

3. Application: Human Resource Core

4. Target Name: sn_hr_core_case_talent_management

5. Type: Table

6. Operation: Read

7. Status: Allowed