- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2019 10:03 AM
Notification Timesheet not submitted to employee
As an employee, if i have not submitted my timesheet for the previous week before Monday at 2pm AEST
I should receive a notification requesting me to do so.
THANKYOU
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2019 10:33 AM
Hi Dexter,
I don't see "user" defined anywhere, it looks like you're trying to use it as a GlideRecord, however it's just a field on the Time Sheet Exceptions table. If you want to call that field you need to use the syntax timecard.user, not just user. Does the Notification run on the sys_user or time_sheet_exception table?
It looks like you have it set up to run on the User table. I would rewrite it this way then. I don't recommend nesting GlideRecords, so we'll build an array of users and then loop through that array to trigger the events. Also I'm going to use an Immediately Invoked Function Expression, instead of defining the function and then calling it. That's just extra steps. Also, use getUniqueValue() function to get sys_id's whenever possible, as you can get some funky behavior otherwise. I always convert sys_id's to strings just out of superstition because of the things I've encountered over the years lol.
I wasn't able to test this of course, but I think this should be pointing you in the right direction. Happy to assist further if needed.
(function () {
var userArr = [];
var timecard = new GlideRecord('time_sheet_exception');
timecard.addQuery('state','Not_Submitted');
timecard.addQuery('week_starts_on<=javascript:gs.daysAgoStart(7)');
timecard.query();
while(timecard.next()){
userArr.push(timecard.user.toString());
}
var user = new GlideRecord('sys_user');
for(var u=0; u < userArr.length; u++){
user.get(userArr[u]);
gs.eventQueue('time_card.late_submit', user, user.getUniqueValue(), user.manager);
gs.log('users' + user.getUniqueValue(), 'timecard');
}
})();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2019 10:40 AM
You haven't mentioned your user details in the query. in your query you have written "timecard.addQuery('state','no_submitted'); in 6th line.
Add one more condition in 7th line to query your timesheet and try this script first on background script and check logs to debug.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2019 08:51 AM
Hi Dexter,
Any updates? Did my answer above solve the issue? If not what issues are you experiencing now?
If my answer did solve the problem, can you please mark it as correct?
Thanks!
Josh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2019 09:12 PM
THANKS JOSH

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2019 09:03 AM
your gs.eventQueue should contain the gliderecord object as the parameter but there i cannot see a user glide record object available in the code
Thanks,
Siva
Mark this response as correct if that really helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2019 09:12 PM
THANK YOU SO MUCH RAGHU , SACHIN AND JOSH FOR YOUR SUPPORT.