- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2025 11:57 AM
I have a Scoped App that has a Custom Table with about 150 records in it. This has been in Production for a while. They want to add a suffix onto one of the fields for all records. The field name is called "security_group", and they want to add "- Role" to the end of every entry of this field.
I created the following Background Script to do that:
var gr = new GlideRecord('x_table_name');
gr.addQuery('active','true');
gr.query();
while(gr.next()){
gr.security_group = gr.security_group + '- Role';
gr.update();
}
when I try to run it, I get the following error messages:
Security restricted: Write operation against 'x_table_name' from scope 'rhino.global' has been refused due to the table's cross-scope access policy
I did some research, and found the following articles:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0727180
I have tried the suggestions in them, including:
1. Tried a "cache.do"
2. Tried running "gs.invalidateCache();" in the background
3. Tried checking the "Can Create" flag on the table
None of that made any difference. So I tried putting the code in a Scheduled Job, and tried running that. That still did not update the records.
Does anyone have any other ideas on how I can make these data updates quickly and efficiently (without having to edit each one manually)? I thought about exporting the records and re-importing them, but the issue is the field I am updating is the key unique field that I would be matching on! And I know it is a bit tricky to figure out how to export the sys_id into an Excel export.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2025 05:13 PM - edited 08-04-2025 05:18 PM
@jmiskey, here's a simple approach.
Follow the steps below.
1) First, have only one field in your list view that you wish to update with the suffix or minimum fields as possible. Like example below.
2) Then click on column context menu and select "Import". Select the options as shown in the example below and click on "Create Excel template". It will process your request and show you download button. Download the template. (Don't include all fields.)
3) This downloaded excel template will have "SysIDs" of all the filtered records along with your selected column that you chose in the list view of you custom table. See example snip below.
4) Now, all that you need to do is concatenate the 2 strings as example below and upload it back with the same interface.
5) Copy and paste the concatenated text to your desired column that you want to update. For example I used "Short Description" field. Do not change any field header. Otherwise it will fail.
6) Save your excel and upload it back from the same interface you downloaded the template.
See example below. If all goes well no error will throw. If error shows up you can fix and upload the excel again.
7) Click on "Preview imported data". Check your updates and scroll to the bottom to complete your import.
Final result...
Hope this helps.
P.S - By the way, did you try fix script? Is it throwing the same error? Not spending too much time there. Try this little trick!
Also, did you check the scope in which you're running your script?
Let me know if it worked!
Regards,
Vikas K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2025 10:57 PM
you are running the background script from global scope and hence the error is coming.
Ensure you select your custom scope here when you Run the script and then it will work for sure
also update script as this
var gr = new GlideRecord('x_table_name');
gr.addQuery('active','true');
gr.query();
while(gr.next()){
gr.security_group = gr.security_group.toString() + '- Role';
gr.update();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2025 03:53 AM
I should have mentioned - I already tried changing to the scope to run the code, and it made no difference - I still got those errors.