Comments between two custom tables - should reflect each other

Robin30
Tera Contributor

Hello everyone,

 

I have issues coming up with a solution for communication between two custom tables.

When a comment is added in the Communication , I want the same comment to appear on my referenced record (and vice versa).

This was done with a Before business rule, but that does not always work as intended.

Sometimes it does not add the comment, and it needs to be posted twice before showing up on form.

 

What is the best way to do this?

Seems like there is not easy solution...

 

The current BR looks something like this:

 

if(current.message_flag==''){
// Send comment
} else {
 
current.message_flag== ''; // set this flag to empty.
}
 
So basically two BEFORE business rules, one on each table.
But this solutions does not capture it all.
If I send a comment from table A ---> Table B , it works, but if i directly send back a comment, that comment does not appear again on table A.
 
Any suggestions on how to make this work all the time?
3 REPLIES 3

Mark Manders
Mega Patron

Create a flow on the sys_journal_field table on insert of a record where name is one of your tables and element is comments. 

Then run an 'if' with condition trigger-name is a, look up record for b and add comment and vice versa. Just make sure you're not creating a loop.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Robin30
Tera Contributor

Thanks for the idea, but is that really needed?

Cannot it not be a flow between just the two custom tables?

 

I have a hard time visualize how the flow conditions should look, and how to make sure it actually copies over the comments

In that case you need two flows, because you can only trigger a flow on one table. Creating it on the sys_journal_field table, only requires one flow. So for 'is that really needed', the answer is 'no', but easier to maintain than your flow between two tables.

 

Trigger on sys_journal_field table where element is comments and name is 'table a' or name is 'table b'.

 

If trigger.name = table A

      look up record for table B where related_field_for_table_a.sysID = trigger.element_id

      update record found by setting comments to trigger.value

 

If trigger.name = table B

      look up record for table A where related_field_for_table_b.sysID = trigger.element_id

      update record found by setting comments to trigger.value

 

 

In case it is a many to many relation, you can do a look up records and then a for each loop to update the records.

 

My advice is to add some 'loop prevention' in there by updating the comments with 'Comment from table x: ' and then the comment. And in your trigger you can add 'value does not contain 'comment from table ' to make sure those aren't copied again.

 

Your own idea can work in the same way, only then you will be creating two flows, doing the same. 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark