After configuring an app relationship, you’ll likely need a way to keep some of the Field values of those apps in sync. If you updated a Field on a parent transaction, you wouldn't want to go through each child transaction and manually update a related Field's value, for instance.
Instead, you can configure an Update Related Transaction(s) Action to keep specific Field values up-to-date with one another. Fields can be kept in sync regardless of whether they share the same name or not.
In this tutorial, we'll set up an Update Related Transactions(s) Action for Fields in related apps.
Before We Start...
This tutorial will assume you understand the following concepts:
Let's Get Started!
In this example, we’ll say we have a parent app named Matter and a child app named Invoices. The Matter app has a Field named matter_number, and the Invoices app has a Field named matter_id. The values for these Fields should stay in sync; if the matter_number is updated for a transaction in the Matter app, we also want the matter_id Field's value to be updated in any of that transaction's children in the Invoices app.
1. Make Child Fields Read Only
If you want your Field values to stay in sync, we recommend allowing only one app's version of that Field to be editable.
In our case, we want a user to be able to update the matter_number Field in the Matter app. However, if a user was still allowed to edit the matter_id Field in the Invoices app, they might update the child's field to throw that invoice transaction out of sync with its parent and the rest of that parent's children.
We'll make our matter_id Field in the Invoices app read-only to prevent this from happening. In the Wizard of our Invoices app, we'll select the Read Only property for our matter_id Field.
2. Create an Update Related Transaction(s) Action to Update the Related Field/s
We can now create our Action.
Browse to the Actions node from your parent App's Advanced Designer.
Add a new Update Related Transaction(s) Action.
Provide this Action with a Name.
Select the name of the Field that draws a relationship to the app you're creating the Action in from the Relation Property dropdown. In our example, that's a HasMany Field named Invoices.
Finally, for the Action's Params Liquid property, use the following format to update the child app's Field with the parent app's Field:
<field_name>:{{field_name}}
Our Action will look like this:
Note: If you're updating a custom Field (that is, a Field that is not one of every app's default Fields: name, requester_name, curr_state_name, etc.) in the Params Liquid property, you must prepend p_ to the Field's Name. E.g., p_matter_id
Tip: If you need to keep more than one set of Fields (with the same name) in sync, you can list each Field parameter on separate lines in the Params Liquid property, as seen in the example below:
p_matter_id: {{matter_number}}
p_matter_type: {{matter_type}}
p_vendor: {{vendor}}
Select OK to save your Action.
3. Tie Your Action to a Transaction Updated Business Rule
Lastly, attach this Action to a Transaction Updated Business Rule to run whenever the parent transaction is updated.
Note: See our Creating a Business Rule tutorial for more help with Business Rules.
Select OK to save your Business Rule.
Test It Out
Good work! You've just configured an Action which will ensure values of specific Fields on your related apps are always in sync.
To try it out, try updating your matter_number Field's value in a parent transaction. Check one of its child transactions to ensure that its matter_id value has been updated.