Trigger Workflow based on Logged-in User

I need to be able to send a form workflow email to the person that is logged in so they have a copy of the order.

In this instance a Salesman is logged into a secure zone and is putting in a customer order so the email autoresponder goes to the customer but the workflow needs to go to the Salesman.

I could set pre-defined workflows (ie. add each person that has secure zone access to their own workflow) but how would I then go about writing an “if” statement based on the person that logged in to trigger the right workfow?

There are 2 ways I can think this might work;

  1. You maintain a code snippet or include that has all the available workflows (setup as a form select element, as per the below documentation link). Each time a workflow is added you’d need to update this.
    Then add that snippet/include into your form so the salesperson can select the relevant item.
    Assuming it’s ok for them to see all other workflow names.
    If there is only one form, you could add this directly to the form layout, but keeping it as a snippet or include makes it cleaner/more manageable.

  2. You save the workflow ID to the salesperson’s CRM record (in an unused field) and then insert it via Liquid (using {{request.currentmember...) to the hidden workflow field in the form.
    Ideal if salesperson shouldn’t see other workflow options and/or to make this automatic for them.

Triggering Workflow docs:
https://docs.treepl.co/content-modules/forms#secTriggerWorkflows

1 Like

@Adam.Wilson that is a brilliant idea. Number 2 would be perfect so we can do this seamlessly. You are seriously good at liquid and I’m loving learning from you :grinning:

1 Like