Trying to change state of Deduplication task records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-05-2023 03:29 AM
Hi All
There is a table reconcile_duplicate_task which i am trying to glide the records and change the state of records which are created after 90 days to Closed Skipped.
I have Used Fix Script/ Scheduled Job to run, before executing want to find how many records are available to do.
So i used background script to find the records, but unable to get count.
below is the script written for Scheduled Job
below is fix script
I need your Suggestions on this and if any wrong please guide me to correct it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-05-2023 05:27 AM
Hi Pvvn,
Try the following changes to your script.
var gr = new GlideRecord('reconcile_duplicate_task');
gr.addQuery('state','Open');
//gr.addQuery('u_created_date','<','gs.beginningOfLast3Months()'); // no custom field in my instance.
gr.addQuery('sys_created_on','<','gs.beginningOfLast3Months()');
gr.query();
gs.info('Number of reconcile_duplicate_task records in last 3 months = ' + gr.getRowCount());
while(gr.next()) {
// gr.state = "Closed Skipped";
gr.state = 7; // the choice value is 7 for "Closed Skipped" OOB
gr.update();
}
Your screenshot show a different script. the 'state' field is inherited from task, and the value 7 is used for "Closed Skipped" OOB. The "Run as" user value probably doesn't have read access to the two tables shown in the Error you're getting. And my Scheduled Script Execution records in sysauto_script table do not start with a function declaration, without a line to call that function, outside of the function definition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-05-2023 11:07 PM
Hi Bert,
Thanks for your Help.
As you suggested i have made changes and i tried it but its showing no records(Zero) while records are there.
Any suggestions over here.
Thanks
pvvn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-06-2023 07:29 AM
Hi Pvvn,
Go to a list view of reconcile_duplicate_task records, build a filter condition like you have in your script, and see what records you get. If you see what you expect, then right-click on the filter breadcrumbs and select "Copy query", use that in
gr.addEncodedQuery('[query_string]');
in place of the 'gr.addQuery();' line and see if the script shows records. If not, I suggest you create a Support Case for what results your get. Try your script logic in Scripts - Background as 'admin' user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-26-2024 06:18 AM
Hi,
I think you don't get results because you are using
gr.addQuery('state', 'Open');
instead
gr.addQuery('state', '1');