FacebookLinkedInTwitter

Utilizing form rules to load information from any entity on forms: E.g. save changes only when specific data is associated

White lightbulb on a black background
FacebookLinkedInTwitter

In this example we’ll take a look at a situation when you don’t want the Resco Mobile CRM app to save changes the user makes to a record, unless there is other particular data associated with it.

When can this be useful?


Your sales reps are following up with a client on a deal, and they need to get in touch with a specific contact from the customer company.
Or, they can save changes to Opportunities only after they have associated products from your portfolio with it.

How can it be achieved?

It is possible to utilize Form Rules to load not only parent record’s data on a child, but also child record’s data, or data from any – even unrelated – entity to a chosen form.
Let’s say we want to make sure that each Account has at least one Contact associated, after this Account has been edited. This can be enabled via the Woodford configuration tool, using the On Save rule on the Account entity.
We will utilize the rule’s Variable section, where not only entity reference via lookup field can be used, but you can also define fetch, that will be used to load data. This is how the rule will look like:
1a
We will create a Variable, where we will load the associated contact record. If the Variable will have a record loaded, it means that at least one contact is associated to the account. This will be specified in the FetchXML. If there is no such contact, the app will display an error message and stop the save of changes made to the Account.
When defining a Variable, first set the type to Entity and enter its name (in our case Contactchild). Then change the Variable’s function to Load Fetch, set target to contact, and click on the three dots next to the empty field to open the filter window, where the actual FetchXML filter is specified:
2a
Now we will create a filter, which will compare the Parent Customer field on Contact with Account’s account ID field using variable. It is a similar approach as in the filtered lookup, in examples, where we filtered contacts using the parent Customer field according to the account ID on an Account.
3a
This is the resulting filter:
4a
Then we just need to specify the condition and the error message step.
The first condition checks if the Variable has at least one record loaded. The “@this” is a pointer to the contact record, so if it does not exist, there is no contact associated. You can use any Contactchild’s field that is required for Contact, e.g. contact’s name.
The second condition is to make sure the rule is not triggered when a new Account record is created, as there cannot be any contact associated until the Account is created, only then you can add associated records.
5a
If the fetch returns more than one record, the first one, that is loaded will be used. The default order is created based on record IDs, ascending. If you want to use a different order, you can export the FetchXML, edit it and import back. This can be done on the FetchXML filter, using the Export/Import command.

Discover more at resco.next 2016

Want to expand your knowledge of Resco Mobile CRM and its Woodford configuration tool even further? Join us at resco.next in Philadelphia or Munich this November for resco.next 2016 and experience two knowledge-packed days filled with hands-on trainings, valuable insights into CRM mobility, and countless opportunities to connect and share experience with fellow attendees, speakers, and the Resco team.

FacebookLinkedInTwitter