Monday, February 25, 2019

Sample Workflow that Prevents Employees from Approving their Own Transactions

Follow these steps to create a workflow that prevents employees from being able to approve transactions that they created.

Note: Some records use the field Approval Status while some use Approved. Take note of which field the record type uses. If the field is not the Approved field then use the correct field where instructions indicate referencing the Approved field.

1. Customization > Lists, Records, & Fields > Transaction Body Fields > New

  • Name the record (Eg Created by)
  • Check Store Value
  • Set Type to List/Record
  • List/Record to Employee
  • In the Applies To tab check any transactions that this should apply to
  • In the Display tab set Display Type to Disabled and set Subtab to Main (The workflow will not work if display type is hidden)
  • In the Validation & Defaulting tab set Dynamic Default to Current User
  • Save


2. Customization > Workflow > Workflows > New

  • Name the workflow
  • Set the Record Type field to Transaction
  • For subtypes select any transactions that this should apply to
  • Set the Release Status field to Released
  • Set Initiation to Event Based. Check both On Create and On Update
  • For the conditions set it so the workflow only run when current user is not empty (to prevent the workflow from interfering with system generated transactions like Voiding Journals)
  • Save  


3. Click the New State.  Name it Entry and save.  Click on the Entry state on the left.

  • Click New Action.  Select Remove Button.  For the Button Id select Approve.  Save the action.
  • Click New Action.  Select Add Button.  Set the label to Approve.  For the conditions set Approved is unchecked.  Save the action.
  • Click New Action. Select Set Field Value. For the event type select Create and Copy, set the Field to Approved and select Static Value for the value (Don't check the Checked checkbox).
  • Click New Action. Select Set Field Display Type. For the Event Type select Create and Copy, the Field to Approved and the Display Type to Disabled.  
  • Click New Action.  Select Set Field Value.  Select Set trigger on to Before User Edit, the Field to Approved and select Static Value for the value (Don't check the Checked checkbox).  For the condition set it so that the custom field from step 1 is Any of User.
  • Click New Action.  Select Set Field Display Type.  Set the Field to Approved and the Display Type to Disabled.  For the condition set it so that the custom field from step 1 is Any of User.

4. Click the New State.  Name it Clicked Approve and save.  Click on the Entry state on the left.

  • Go to the transitions tab and create a new transition.  Set the State to Clicked Approve and for the Button field select Approved (The custom button created in step 3).
  • Click on the Clicked Approve state.
  • Click New Action.  Select Set Field Value.  Select the Field to Approved and select Static Value for the value. Check the Checked checkbox.  For the condition set it so that the custom field from step 1 is None of User.
  • Click New Action.  Select Return User Error.  For the condition set it so that the custom field from step 1 is Any of User.  For the text set it to "You cannot approve a transaction that you created".


Notes:

-This workflow replaces the default Approve button with a custom one.  It is possible for this to affect the functionality of other workflows or scripts that rely on the approve button.
-This will only work for transactions created after the workflow is created.  Older ones will be able to be approved by employees who created them (The same as before creating the workflow).
-An alternate solution to this is to add conditions to the Add Button action so that it only shows if the user can approve it instead of seeing a message telling the employee why they cannot approve it.  Then it is possible to skip step 4.

No comments:

Post a Comment