How do you set the application scope in a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2017 08:57 AM
There has to be a way to do this.
I need to delete about 28,000 records that were created by mistake during an import (I forgot to set the number field to coalesce=true!). Normally, I would just go to sys.scripts.do, do an encoded query on the table, and then run deleteMultiple. But it's a scoped application, and it's not letting me run deleteMultiple from the Global scope.
The little dropdown at the bottom that allows you to specify what scope you want to run it in only contains "global".
How do I run a script in a specific application scope?
This is the script I tried to run:
var hr=new GlideRecord('sn_hr_core_case');
hr.addEncodedQuery('sys_created_by=rick seiden');
hr.deleteMultiple();
But it said "Security restricted: Delete operation against 'sn_hr_core_case' from scope 'rhino.global' has been refused due to the table's cross-scope access policy"
I tried to add a sys_scope_privilege for GlideRecord.deleteMultiple, and got the same result.
Thanks for your help
Rick Seiden
PS: If this is a bad idea to try and allow deleteMultiple from the Global Scope, or run a script in a specific scope from sys.scripts.do, please tell me how to mass delete 28,000 records without deleting all records on the table (I want to keep some of them).
PPS: I tried writing a script include in the proper scope and calling that script include from the Global scope. That didn't work.
PPPS: I tried exporting the records I want to keep to an XML file and then using the Delete All Records feature of the Table module on the table. I got the same error as running it from sys.scripts.do
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2017 10:23 AM
I figured out a work around, but I'm still open for a "real" answer.
What I did was create a UI action on the application's form that ran the deleteMultiple script. Then I queried for records I wanted to keep (so I wouldn't be deleting records from a record I want to delete), and hit the button. The records are slowly being deleted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2017 10:25 AM
And, it timed out after deleting a small subset of the records I need to delete. Still facing 280,000 records that need deleting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2017 05:49 AM
At least since Helsinki there is a small dropdown to select the application scope next to the "Run script" Button in sys_scripts.do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2017 06:32 AM
The problem is that you can only select scopes you've created yourself from what I can see.
If you want to delete something from the HR scope you'll run in to this problem.