Cross-scope access issues for field creation

Vijay Baokar
Kilo Sage

Hi All,

 

Since i am working on scoped app where i need to create fields in bulk on a custom table. I am using fixed script just to check whether filed can be created in scoped app table. Below is the script however field is not getting created instead giving an error:

 

Error:

Security restricted: Access to api 'put(sys_dictionary.name)' from scope 'x_ihpp2_sup_scoped' has been refused due to the api's cross-scope access policy.
Security restricted: Access to api 'put(sys_dictionary.internal_type)' from scope 'x_ihpp2_sup_scoped' has been refused due to the api's cross-scope access policy.
Security restricted: Access to api 'put(sys_dictionary.column_label)' from scope 'x_ihpp2_sup_scoped' has been refused due to the api's cross-scope access policy.
Security restricted: Access to api 'put(sys_dictionary.element)' from scope 'x_ihpp2_sup_scoped' has been refused due to the api's cross-scope access policy.
Security restricted: Create operation against 'sys_dictionary' from scope 'x_ihpp2_sup_scoped' has been refused due to the table's cross-scope access policy

 

 

Script:

 

var fields = [
    {label: 'Error Code', name: 'u_error_code', type: 'string'}
   
];

fields.forEach(function(field) {
    var gr = new GlideRecord('sys_dictionary');
    gr.initialize();
    gr.name = 'x_ihpp2_sup_scoped_hp_payfile'; // Table name
    gr.internal_type = field.type; // Field type
    gr.column_label = field.label; // Field label
    gr.element = field.name; // Field name
    gr.insert();
});

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Vijay Baokar 

I recommend not to use any script to create a field as it might lead to some issue as the field won't be captured correctly in update set.

Please create them manually and inform customer that it will require time

The time you invest in debugging the cross scope issue, by that time you will actually end up creating the fields manually.

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

View solution in original post

2 REPLIES 2

Tushar
Kilo Sage
Kilo Sage

Hi @Vijay Baokar I think scoped app (x_ihpp2_sup_scoped) doesn’t have the necessary cross-scope privileges to create or modify records in the sys_dictionary table, which is in the global scope so ServiceNow restricts direct access to sys_dictionary from scoped apps unless explicitly allowed.

Ankur Bawiskar
Tera Patron
Tera Patron

@Vijay Baokar 

I recommend not to use any script to create a field as it might lead to some issue as the field won't be captured correctly in update set.

Please create them manually and inform customer that it will require time

The time you invest in debugging the cross scope issue, by that time you will actually end up creating the fields manually.

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