business rule is running twice on single update

P Seth
Tera Contributor

I have 2 business rule one is on Before update and another is on After insert and update. 
1. Before Update BR: 
- Condition : State = On Hold && Sub state = Customer && Additional Comment CHANGES

 

if (current.requested_for == gs.getUserID()) //if comment is updated by same as user in requested for
	{
		current.pending_target_date = chaging to NULL
		current.substate = changing to NULL
		current.state = WIP
 fire an event (event 1)
	}

 

2. After insert/update BR : 
Condition : Additional Comment CHANGES 

 

if (previous.state == 'On Hold' && current.state == 'WIP' && current.requested_for == gs.getUserID()) {
        gs.info(' CONDITION PASSED');
        return;
    } 
else { // for updates on comments 
        gs.info('RUNNING TWICE');
        Fire Event 2
    }

 

 

But when RITM state is On Hold and User( requested for) does and update. 
BR1 runs successfully fires event 1 and BR2 runs Twice , Firstly i see 1st log statement "CONDITION PASSED" and then 2nd Log statement "RUNNING TWICE". and Fires Event 2  which is not ideal. as i want to suppress the BR2 completely  when BR1 is running .
Query : 
why the BR2 is Running twice ? and at second time why the if statement is getting passed and moving to else firing event 2 ideally it should return from if condition only.

1 REPLY 1

GlideFather
Tera Patron

Hi @P Seth,

 

you have raised this question already 4 times, while for 2 of them you accepted the solution... if the solution was not delivered, why did you mark it as complete?

If you have one question and you open it 4x then it will shatter the focus and you will get your answers less likely  as you might get answers in separate places while the respondents might get any other idea when they discuss within one place instead of 4 different places...

 

Is there any specific need that you raised it several times even after you accepted the solution? It's enough to post it once, no need to add it to different places (developer forum x architect forum)..

 

business rule is running twice on single update 

business rule running twice on single Update

Business Rule firing twice on RITM update when in On Hold state 

Business Rule firing twice on RITM update when in On Hold state

 

Please, is it solved - solution is accepted or not solved?

 

 

 

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */