Double addition in Before Business Rule

lonesoac01
Giga Guru

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?

7 REPLIES 7

Adrian Ubeda
Mega Sage
Mega Sage

Hello lonesoac1, 

I assume that the condition that triggers that BR is that you update any field when you do a rejection. Try this Business rule on after, instead on before and also, be more restricted in terms on conditions to control exactly when you want to trigger this BR.

If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆

Bert_c1
Kilo Patron

Query the BR table, for table=[table name in your BR], and Script contains 'u_rejection_count'. Review those. 

Anurag Tripathi
Mega Patron
Mega Patron

Your intuition is correct. The transaction is happening twice and that is why you see this.

Most likely cause: Check if there is any other BR that has current.update() on it?

-Anurag

Bert_c1
Kilo Patron

Try:

current.u_rejection_count = previous.u_rejection_count + 1;