I'm trying to build a workflow in that reads the attached Contacts to the Opportunities, specifically their contactRole. I have "Contact Role equals Role" in the conditions, but it's not reading this. Is there a better workaround for this?
Workflow for Contact Roles Attached to Opportunities
Collapse
X
-
Hi bgpus,
Consider using the Execute Formula Script action with the following formula script:
Code:// CONDITIONS $oppId = workflow\targetEntity\attribute('id'); $contactsIds = record\findRelatedMany('Opportunity', $oppId, 'contacts', 100, 'createdAt', 'desc'); $i = 0; while ($i < array\length($contactsIds)) { $contactId = array\at($contactsIds, $i); $role = record\relationColumn('Opportunity', $oppId, 'contacts', $contactId, 'role'); $roles = array\push($roles, $role); $i = $i + 1; } // ACTIONS if (array\includes($roles, 'Landlord')) { record\update('Opportunity', $oppId, 'description', 'There is related contact with Landlord role.') } else { record\update('Opportunity', $oppId, 'description', 'There is not related contact with Landlord role.') }
👍 1
Comment