- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 04:41 AM
Hi Experts
I have a really weird issue.
I am working on the Time Card Module and Table.
I have a list where it is showing me my Current Time for this week.
and I am listing the Total of the Days.
What I want is to not allowing to add more than 8 hours per one day on this list.
e.g. on Monday shouldnt be more than 8 as total.
I have created a Business Rule on Time Card to run "After" when Sunday changes.
in this BR i am GlideAggregate with this list.
All is working fine , the calculation is working but when I need to reset the field (Sunday) if Total more than 8. with:
current.sunday = 0;
current.update();
sometime it is working and sometime it isnt reseting to 0.
Andybody has an idea?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 06:45 AM
I found the solution my self
As the current.update() on After BR is not working properly I had to do a workaround and this is working all the time
this my solution Code:
var gr = new GlideRecord('time_card');
gr.addQuery('sys_id', current.sys_id);
gr.query();
while (gr.next()) {
gr.sunday = previous.sunday;
gr.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 04:55 AM
More weird is that I have debug this BR and even it is not working on the debug it is showing me all the time that the record current.sunday is reset to 0
sunday: 5 => 0
sunday: 4 => 0
sunday: 4 => 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 06:45 AM
I found the solution my self
As the current.update() on After BR is not working properly I had to do a workaround and this is working all the time
this my solution Code:
var gr = new GlideRecord('time_card');
gr.addQuery('sys_id', current.sys_id);
gr.query();
while (gr.next()) {
gr.sunday = previous.sunday;
gr.update();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 07:21 AM
On a side note, you want to be very wary of using current.update() in business rules....especially After business rules. See section four in this article: Business Rules Best Practices - ServiceNow Wiki