Process Definition trigger in relation to LogicHooks

I hope this is a relatively simple question. In Sugar 9.x, what order does the process definition triggering event fall in relation to LogicHooks? Is it an after_save or a before_save event? What is the order of the event in relation to other Logichooks?

I found two articles/answer on the Community site. This is the most recent response, which the gentlemen states that the Process Definitions fire on a "before_save", but the user doesn't state what order it falls in the "before_save"

https://community.sugarcrm.com/thread/34843-execute-logichook-after-workflow

The second article/answer I found stated that the Advanced Workflow (which was the old version of Process Definitions) was an after_save event with an order number of 100. This article/answer is more than likely out of date as it was from 11/22/17.

https://community.sugarcrm.com/thread/31066-how-to-define-logic-hook-alongside-advance-workflow

Since there is different information out there and I can't find the answer in the documentation and there isn't anything out there from an official response from Sugar, I figured it'd be best to ask the community.

Thanks!

  • Hi Tim Crishi,

    I had the same confusion which you have and I also check both articles. I think there is some wording confusion in Execute LogicHook after Workflow  , If you will read this answer in-depth and apply it to some test record it will work rock.

     Let me try to clarify the confusion.

    "Workflow executes on before_save logic hook" means Workflow is the very first operation that executes in the after_save. It means if you will write an after_save logic hook regarding the processing order firstly it will call for the "Process Definition" module and then for the relevant module for which it is written.

    But just changing the process order number is not enough. Because during the workflow execution it further executes 2 times, one for workflow and 2nd for adding an entry in the 'locked_field_bean_rel' table.

    So thumb point is that never depends on processing order it can vary. So simplified solution is that checking the $arguments['related_module'] in after_save logic hook and write you implementation only if the related module must not Process Definition.

    For further clarification, you can say assume the following order.

    1) Before save

    2) After save (for workflow)

    3) After save (for the relevant module)