Trigger business rule

Vaibhav Kumar Y
Tera Expert

Hello All,

I need to trigger the business rule if there is any insert or update happens to sc_task table. But if only attachment is getting inserted then the business rule is not getting triggered.
And if I write the business rule for sys_attachment table and for sc_task table. Then if there is any update to the fields and attachment insert at same time from REST, then it is getting triggered two times. One from sys_attachment and one from sc_task.
How can I handle this if there is any insert to the table with attachment by REST then it should trigger only one time
Kindly help me for the solution

6 REPLIES 6

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,
I hope you are using onAfter BR?

 

 


Thanks and Regards,

Saurabh Gupta

Community Alums
Not applicable

Hi @Vaibhav Kumar Y ,

 

Please use async business rule and business rule will trigger only once. You can also use setWorkflow(false) to stop BR execution.

 

Thank you,

Santosh Poudel

Abhay Kumar1
Giga Sage

@Vaibhav Kumar Y i understand your problem and I can probably think of just having one BR that too after insert/update as per requirement.

And user logic to check using attachment table whether attachment is available or not, then run you inside if else.

Hope this will help you.

OlaN
Giga Sage
Giga Sage

Hi,

So the problem is that you have three different scenarios that could happen, and you want to catch them all.

1. An update happens to the sc_task record

2. An insert happens on the sys_attachment record, that is connected to a sc_task record

3. Both 1 and 2 happens at the same time.

Not sure if it's possible to solve it all in one business rule, but there are ways to work around this.

 

Here is one suggestion (not tested)

Add a field on the sc_task table for example "u_attachment_counter"

*Create a business rule that triggers on update of sc_task record, and set a condition that u_attachment_counter is not changed. This business rule will cover scenario 1.

*Create a business rule that triggers on insert (and delete) of sys_attachment record related to the sc_task table, have the business rule update the field of u_attachment_counter.

*Create a second business rule that triggers on update of sc_task record, and set it's condition to only run when the u_attachment_counter value changes. This will cover scenario 2 and 3.

 

Hope this helps!