Custom WorkFlow Order of Operations

Workflow #1: I have a workflow which looks for new Leads, takes a lead, converts it to Account, relates Account to Lead, and creates a Custom Object also related to Account.

Workflow #2: I have another workflow which looks for new Custom Object, does something with the related Account.

If I create a new Custom Object and assign it an Account in the form, everything works as expected.

If I have Workflow #2 disabled, and I create a Lead, all my objects are created correctly with correct relationships.

If I have both Workflows enabled and create a Lead, my custom action on the Custom Object fails. While debugging, it looks like it’s attempting to fire off the Custom Object creation in Workflow #2 before it’s linked the Custom Object to the Account which happens as a first Action of Workflow #1.

Anyone have an idea on how the order of operations on Workflows works and/or why this would be happening and how to fix it?

I figured it out, but don’t know how to solve it.


# modules/AOW_Actions/actions/actionCreateRecord.php:169
                $this->set_record($record, $bean, $params);
                $this->set_relationships($record, $bean, $params);

This will actually do a $bean::save() in the set_record, which triggers Workflow #2 before calling set_relationships()