Skip to content

Jenwlee's Salesforce Blog

Sharing my love for Salesforce with my #Ohana

  • How To
  • Salesforce Release
    • Summer ’21 Release Highlights
    • Spring ’21 Release Highlights
    • Winter ’21 Release Highlights
    • Summer ’20 Release Highlights
    • Spring ’20 Release Highlights
    • Winter ’20 Release Highlights
    • Summer ’19 Release Highlights
    • Spring ’19 Release Highlights
    • Winter ’19 Release Highlights
    • Summer ’18 Release Highlights
    • Spring ’18 Release Highlights
    • Winter ’18 Release Highlights
    • Summer ’17 Release Highlights
  • Certification
    • How I Studied for the Platform Developer I (Beta) Exam
    • How I Studied for the Sales Cloud Consultant Certification Exam
    • How I Studied for the Sharing & Visibility Designer Exam
    • How I Studied for the Data Architecture and Management Designer Exam
    • How I Studied for the Salesforce Platform App Builder Certification Exam
    • Salesforce Administrator Exam Preparation & Exam Taking Strategy
    • How I Studied for the Salesforce Advanced Administrator Certification Exam
  • Salesforce Events
  • Trailhead
  • About Me
  • Meet Jen Lee
How To

Using Custom Metadata Type in Visual Workflow Fault Emails

February 2, 2016March 25, 2016 jenwlee

Here are lessons learned you will take away from this blog post:

  • As a best practice, include a Send Flow element for each record action (lookup, create, update and delete) to send a notification to the production support team when an error occur.
  • Avoid “hardcoding information” in visual workflow, especially information that can be different in each region of a related org. This would cause updates to the visual flow in each region, making for different versions of the same flow.
  • Maintain information that are referenced in multiple visual workflows outside of flow. Increase ease of maintenance. If the information needs to change, it is only changed in one place.
  • New use case for custom metadata type.
  • Data records associated with a custom metadata type are deployable via a changeset. You can locate the data records by looking for the custom metadata type’s name under the Component list. Do not look for it under Custom Metadata Type.

For those of you who are regulars to my blog, you know that I include a Send Email flow element step in visual workflow implementation. As a best practice, where there is a DML action (fast or record create, update, delete or lookup action) in a flow, you should also include notification of a flow fault. In those examples, I list out a single Send Email flow element with the recipient email address listed in each.

OriginalFlow

OriginalSendEmailFlow.JPG

You can see over time, how that may not help ease maintenance. What if Addison Dogster leaves the company or there are others who need to receive the email? A System Administrator would need to go into each flow and update the email recipient and deploy the change to Production.

We can remove the specific email addresses from within the flow and maintain them outside of the visual workflows. If the email recipient needs to change, update it once and it updates it in all the flows. This also allows the System Administrator to be able to change the email recipient to her/his email address in the sandbox region as they build/troubleshoot a new visual workflow and not clog the emailboxes of the production support team.

We can also add enhancements to the fault email function, such as including the region that the email was sent from.

While we can solution this with custom settings, we will be using custom metadata type instead.

Quick sidebar on custom metadata types, this is a great feature to add to your admin toolset! If you like custom settings, you will REALLY like custom metadata types.

Custom metadata types are new to Salesforce, introduced in Winter 16.

Custom metadata is customizable, deployable, packageable, and upgradeable application metadata. First, you create a custom metadata type, which defines the form of the application metadata. Then you build reusable functionality that determines the behavior based on metadata of that type. Similar to a custom object or custom setting, a custom metadata type has a list of custom fields that represent aspects of the metadata. Unlike custom settings, the record data is metadata and can be deployed with the custom metadata type in a Change Set. No more exporting the related data and importing it to the destination org as you would do when deploying a custom setting.

For more information on custom metadata types, visit Salesforce Help & Training.

To make this piece more flexible, easier to maintain, this will require updates to your existing workflows. I can hear the big sighs now. Sorry! If you have many workflows, perhaps consider deferring the tweaking until the next time you touch the visual flow for other purposes.

Implement the following steps in each of your visual flows to retrieve the email recipients and the current Salesforce region to be pulled into the Send Fault Email flow element.

Business Use Case: Addison Dogster is a system administrator at Universal Container. She has implemented several visual workflows in her organization. Her team has grown over time and there is now a team of individuals who need to be notified when there are issues with visual workflow. When a fault email is sent from a sandbox, there is no indication which sandbox. She now needs to come up with a solution to easily maintain and enhance these fault emails.   

Solution: Addison was able to address these enhancements via declarative actions, no code. Her solution involves a creation of custom metadata type and a changes to visual flow.

Quick Steps:

Step 1. Create a Custom Metadata Type (Develop | Custom Metadata Types), click on the “New Custom Metadata Type” button.

A. Provide the label name, label name in plural, description and click the “Save” button.

Best Practice Tip: Don’t forget to provide a description so you and other/future admins know what this custom metadata type is used for.

CustomMetadataType-New.JPG

The resulting page looks very similar to a standard/custom object in terms of standard, custom fields and page layout.

CustomMetadataType.JPG

B. We will create a new custom field to hold the email recipients.

Best Practice Tip: Don’t forget to provide a description so you and other/future admins know what this custom field is used for.

CustomMetadataType-Email.JPG

C. We will create another new custom field. This one will hold the org-region name.

Best Practice Tip: Don’t forget to provide a description so you and other/future admins know what this custom field is used for.

CustomMetadataType-OrgRegion.JPG

D. Let’s update the Fault Email Page Layout. Move the unnecessary fields to the System Information section and make the Information section one column. Save the changes.

CustomMetadataType-PageLayout.JPG

E. Let’s create the custom metadata type data record that stores the specific fault email information.

Click on the “Manage Fault Email Addresses” button.

CustomMetadataType-CreateDataRecord

Provide the Master Label (name of the data record), Email and Org-Region Name. Note: the Object Name will be populated with the Master Label value. Save the data record.

CustomMetadataType-DataRecord.JPG

Step 2. We are now going to make the following highlighted updates to your existing visual workflow. Go to Create | Workflows & Approvals | Flows.

FaultEmail

A. Create these two variables. They will store the email and org-name values pulled from the custom metadata type data record created in the previous step.

varEmailRecipients.JPG

varOrgRegionName.JPG

B. Create a Record Lookup. This will lookup the custom metadata type and pull in the email recipients and org-region name in the variables created in Step 2A. Lookup: Locate the Custom Metadata Type API name

We will use MasterLabel of the Custom Metadata Type data record as the criteria.

CustomMetadataType-RecordLookup.JPG

CustomMetadataType-RecordLookup1.JPG

C. (If updating an existing flow – open the Send Email flow element) Select the Send Email flow element that is listed under Static Actions, not under Quick Actions.

StaticActions

Configure the body to show the fault message, subject and email address(es).

Body: Fault Message: {!$Flow.FaultMessage}

Subject: {!varOrgRegionName} Error – <Name of the flow>

Email Addresses (comma-separated): {!varEmailRecipients}

UpdatedSendEmail.JPG

Best practice tip: Don’t forget to provide a description so you and other/future admins know what this send email element is supposed to do.

Note: You will need to draw a FAULT connector line between each Fast/Record flow element to the Record Lookup for the Fault Email Recipients and then a regular connector to the Send Email element.

FaultEmail

Can’t seem to get the fault connector to appear? Create a temporary flow element (circled below), draw your first connector to that temporary flow element. Then, draw another connector to the send element. This connector has the word “FAULT” in it.  

Once that is completed, delete the temporary flow element you created. This is the end result.

Deployment Notes/Tips:

  • The custom metadata types and associated data record and visual flow can be deployed to Production in a change set.
  • You will find the custom metadata type information under the Custom Metadata Type in the Component Type dropdown. However, locate the data records for the custom metadata types by looking for the custom metadata type names in the Component Types dropdown.
  • You will find the visual workflow components in a change set under the Flow Definition component type.
  • Activate the visual flow after they are deployed in Production as it is deployed as inactive.

Share this:

  • Tweet

Like this:

Like Loading...

Related

Share this:

  • Tweet

Like this:

Like Loading...
Custom Metadata Type Flow Salesforce visual workflow

Post navigation

Previous Post Auto Assign Public Groups to Users Based on Profile
Next Post Simplify Maintenance of Profile or User References in Validation Rules Using Custom Settings and Custom Permissions

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 12,834 other subscribers

Check out my previous posts

About the Author

Native Bostonian. 4x Salesforce MVP, Dreamforce 16-19 presenter & other Salesforce and community hosted events, 8x Salesforce Certified (Salesforce Application Architech, Salesforce Administrator, Advanced Administrator, Platform App Builder, Sales Cloud Consultant, Security and Visibility Designer, Data Management and Architecture Designer, Platform Developer I), co-host of Automation Hour, Salesforce enthusiast and blogger, Trailhead addict (8x Ranger!), #LifeWithGoldie, and Lightning Champion.

Named Salesforce MVP on 7/29/16

Trailblazer!

Salesforce Trailblazer post published on 8/16/17.

#AwesomeAdmin Award Recipient

I am so truly honored to be the recipient of Salesforce's #AwesomeAdmin Award at the 2016 Boston Salesforce World Tour.

1/14/16 Girly Geek of the Week

My Tweets
Website Powered by WordPress.com.
  • Follow Following
    • Jenwlee's Salesforce Blog
    • Join 1,672 other followers
    • Already have a WordPress.com account? Log in now.
    • Jenwlee's Salesforce Blog
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • View post in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...
 

    %d bloggers like this:
      %d bloggers like this: