Today I have a task to create a workflow which starts when a record is created. Then it waits for a while and check if there are any other records associated with this record. For example, when an Account is created, after a period of time, we want to know, is there any Contacts associated with this Account.
It doesn’t sound difficult. We can find those Contacts by Advanced Find like this:
However, in workflow’s If condition, there is no Contact in related entities:
Because it is One-To-Many relationship between Parent Customers (Account) and Contact, we need to figure out another way to check associated Contacts exist for this Account in workflow.
First of all, let’s create a two option field called “Is Linked by Contact”. It is better if we hide that field on form, but just show here for testing.
Then register a plugin in create/update/delete of Contact.
• In create stage, check parent customer’s value. If contains data, update that Account’s field to “Yes”.Now we can use that Boolean field in workflow like this:
At the end, let’s test that workflow.
• Create an Account and link a Contact in 5 minutes.