Duplicate records at weekly aggregate table

joshuastanley
Tera Expert

Hi All,

We are having duplicates at weekly aggregates table when the timesheet submitted from the timesheet portal. Have anyone faced similiar situation. Is so how to track this down and find out the script creating the duplicates.

 

Regards, Joshua

1 ACCEPTED SOLUTION

joshuastanley
Tera Expert

Hi All,

Just got an update from support saying that this issue might be due to the multi node processing enabled. This might result in the creation of duplicate records at the same time. Please keep this in mind when getting duplicate records at any application, look for any event processing by multi node mode.

 

Thanks.

View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

@joshuastanley 

please share what's the report condition and the screenshots etc

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

Thanks Ankur, we are getting duplicate values at resource_aggregate_weekly table for unique of user, task,categlry &  week_starts_on. one record updated by system and other record updated by admin.

joshuastanley
Tera Expert

The query which I use to find the duplicates as below

// Identifying the aggregate duplicates

var dupeCount = 0;
var gaMyTableDuplicate = new GlideAggregate('resource_aggregate_weekly');
gaMyTableDuplicate.addQuery('week_starts_on', '>', '2024-11-01');
gaMyTableDuplicate.addAggregate('COUNT');
gaMyTableDuplicate.groupBy('user');
gaMyTableDuplicate.groupBy('task');
gaMyTableDuplicate.groupBy('category');
gaMyTableDuplicate.groupBy('week_starts_on');
gaMyTableDuplicate.addHaving('COUNT', '>', 1);
gaMyTableDuplicate.query();

while (gaMyTableDuplicate.next()) {
dupeCount = gaMyTableDuplicate.getAggregate('COUNT');
gs.info(
dupeCount + ' records found with the following identical values:\n' +
'•User: ' + (gaMyTableDuplicate.user.getDisplayValue() || '(blank)') + '\n' +
'•Category: ' + (gaMyTableDuplicate.category.getDisplayValue() || '(blank)') + '\n' +
'•Task: ' + (gaMyTableDuplicate.task.getDisplayValue() || '(blank)') + '\n' +
'•Week Starts: ' + (gaMyTableDuplicate.week_starts_on.getDisplayValue() || '(blank)') + '\n\n'
);

}

joshuastanley
Tera Expert

Is it a good idea to enable the audit on the resource_weekly_aggregate table, which undergoes 20000 times updated over a week time. Please let me know your suggestions.