Time Sheets and Time Sheet Exceptions Table

rdskn023ET
Tera Contributor

Hi,

 

Has anyone ran into an issue where time sheets are setup to be automatically generated on a weekly basis and the time sheet exception table is displaying incorrect results when those time sheets are deleted at a later time? For instance, in our case, we generate time sheets for all active employees who are part of a specific group within in the organization. If someone leaves the organization without notifying our group, which happens often within a large organization, we then have to go back and delete the time sheets for those users. However, for those using the time sheet exception dashboard reports, it seems that those time sheets remain as unsubmitted in the reporting data, even though they no longer exist since being deleted. Has anyone experienced something like this or written something to automatically delete the record in the time sheet exception table once the actual time sheet has been deleted? Any insight would be greatly appreciated! Thanks!

1 ACCEPTED SOLUTION

Kristen Dettman
Kilo Sage
Kilo Sage

In case anyone is still interested, I was looking to do the same thing, but neither of the suggested approaches worked because there is no field directly tying the Time Sheet Exception to its Time Sheet. However, I found that if I queried the same User and Week Starts On, it worked like a charm!

 

var user = current.user;
var week = current.week_starts_on;

var exceptionTable = new GlideRecord('time_sheet_exception');
exceptionTable.addQuery('user', user);
exceptionTable.addQuery('week_starts_on', week);
exceptionTable.query();
exceptionTable.deleteMultiple();

View solution in original post

5 REPLIES 5

Kristen Dettman
Kilo Sage
Kilo Sage

In case anyone is still interested, I was looking to do the same thing, but neither of the suggested approaches worked because there is no field directly tying the Time Sheet Exception to its Time Sheet. However, I found that if I queried the same User and Week Starts On, it worked like a charm!

 

var user = current.user;
var week = current.week_starts_on;

var exceptionTable = new GlideRecord('time_sheet_exception');
exceptionTable.addQuery('user', user);
exceptionTable.addQuery('week_starts_on', week);
exceptionTable.query();
exceptionTable.deleteMultiple();