- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2020 06:38 PM
I tried "gs.warn", "gs.error", in addition to gs.info, but no log is displayed in the application log.
Is there a solution?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2020 07:14 AM
So that screenshot shows the BR being an "after" BR and NOT a "display" one. Can you please change it to "display" and then show a screenshot of the "Advanced" tab as well please.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2020 08:06 PM
Can you add a screenshot of the top part of the Business Rule itself? I just want to make sure it is indeed active AND running on the Incident table.
Also, it looks like you've completely changed the structure of the code itself (which is why it's not running I believe). The default code should look something like this:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
})(current, previous);
So your code should look something like this:
(function executeRule(current, previous /*null when async*/ ) {
gs.info("JC - Finally running!!!");
var total = 0;
var gr = new GlideRecord('task_time_worked'); //related list table name
gr.addQuery("task", current.getValue('sys_id'));
gr.query();
while (gr.next()) {
total += gr.time_worked.dateNumericValue();
}
current.u_total_time_worked.setDateNumericValue(total);
})(current, previous);
I changed your query so that it's looking at the "task" field and not "incident". So if we got the BR working (and I think it finally will), you would have ended up calculating time worked for ALL Tasks!!!!! And is the field name you want to update called "u_total_time_worked" or "total_time_worked" without the "u_" prefix?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2020 10:00 PM
a screenshot of the top part of the Business Rule
sys_dictionary "u_total_time_worked"
I tried the modified script but it didn't work. No logs were displayed. Is BR not performing well?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2020 07:14 AM
So that screenshot shows the BR being an "after" BR and NOT a "display" one. Can you please change it to "display" and then show a screenshot of the "Advanced" tab as well please.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2020 05:22 PM
Changing BR to "after" solved the problem. Thank you very much.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2020 06:14 PM
Hello...can you clarify what was the correct answer. Just for future readers?
Your BR was already an after and Jim was asking for you to change it to something else...then you replied and said changing it to after worked.
What was the solution then?
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!