Double addition in Before Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 07:43 AM
Hello all,
I have a Before business rule that is adding to an integer field twice. Here is the code:
current.u_rejection_count = current.u_rejection_count + 1;
As you can see, the intent is just to add one to whatever number was originally in the field. It should be yielding results such as:
First rejection:
0 (default value) + 1 = 1
Second rejection:
1 + 1 = 2
etc.
What is happening is:
First rejection:
0 (default value) + 1 = 1
1 + 1 = 2
Second rejection:
2 + 1 = 3
3 + 1 = 4
My intuition is telling me that somehow another BR is causing this, but I am not sure. What am I missing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 09:34 AM
HI @lonesoac01 ,
I trust you are doing great.
You can try debugging the BR.
- ou can use the
gs.info()
method to add debugging statements within your BR to get more insights into when and how it’s being executed.
Here is a revised version of your code with debugging statements:
(function executeRule(current, previous /*null when async*/) {
// Debugging: Log the current value of u_rejection_count
gs.info("Before BR: u_rejection_count = " + current.u_rejection_count);
current.u_rejection_count = current.u_rejection_count + 1;
// Debugging: Log the updated value of u_rejection_count
gs.info("After BR: u_rejection_count = " + current.u_rejection_count);
})(current, previous);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 06:47 AM - edited 11-01-2023 06:48 AM
Hello all,
An update on the situation. I think I might have found a correlation between the running of the business rule twice and a related list. I am seeing a rejection count of 3 and I am seeing a total of three rejections in the metrics related list. I only rejected the request twice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 06:56 AM - edited 11-01-2023 06:58 AM
I went into the Metric definition, and it seems to be watching the Approval field. Whatever is going on, it is clearly happening on the change_request table.