Sunday, December 23, 2018

Send an Email when a Field's Value Changed via Workflow

Similar to SuiteScript, the Workflow Manager has the capability to reference a record's values as documented on the help guide at Help> SuiteFlow (Workflow) SuiteFlow Reference and Examples Condition Examples Referencing Old (Pre-edit) Values in a Workflow. However, this will only work for Before Record Submit triggers.

On the other hand, there are workflow actions wherein the trigger Before Record Submit will not work, like the Send Email action. This article demonstrates the solution for this.

1. Create custom body field that will act as a flag to determine if there was a field value change. Go to  Customization > Lists, Records, & Fields> Transaction Body Fields > New.
   - Name: Email Sent 
   - Type = Checkbox
   - Applies to: Opportunity = True
   - Store Value = True
   - Save

2. Create a new workflow by navigating to Customization > Scripting > Workflows > New.
 
3. Define the workflow
   a. Name = Send Email when Engineer changed
   b. Record Type = Opportunity
   c. Release Status = Released
   e. On Update = True
   f. Trigger Type = All
   g. Click Save.
 
4. Click State 1 and edit the Name . Set it to Send Email, then hit Save.

5. To create an action to the state, click on the Send Email state and click New Action. 
   a. Select Set Field Value.
   b. Trigger On = Before Record Submit
   c. Condition: Old Record : Title != Title
   d. Parameters: Field = Email Sent
   e. Value:
      e.1. Static Value = True
      e.2. Checked = True
   f. Click Save. 
 
7. Click on the Send Email state and click New Action.
   a. Select Send Email.
   b. Trigger On = After Record Submit
   c. Condition: Email Sent = T
   d. Specific Sender = <choose any from your employee record>
   e. Specific Recipient = <choose any from your employee record>
   f. Content
      - Select 'Custom' button.
   - Subject: Send Email
   g. Click Save.
 
8. Create another Set Field Value action to set Sent Email = True once more. This is to ensure that any future changes will be tracked
   a. Select Set Field Value.
   b. Trigger On = After Record Submit
   c. Condition: Email Sent = T
   d. Parameters: Field = Email Sent
   e. Value:
      e.1. Static Value = True
   e.2. Checked = False
   f. Click Save.

9. Edit one of your Opportunity records, change the value of the Title field and save it. On any change on the said field, the intended recipient will receive an email.

No comments:

Post a Comment