Showing posts with label error. Show all posts
Showing posts with label error. Show all posts

Saturday, June 28, 2014

Avoid Flow Trigger Errors Associated With User Records

With Summer '14, more users are finding more to processes to automate with Flow Triggers.  This is just a note to let you know that the User record does not behave like other records when used in a Workflow rule.  It can cause "MIXED DML OPERATION" errors, and simply report that your "trigger failed to execute the flow with version ID 30111000000..." or something very similar.

A time-based trigger can be set to fire behind another trigger.
This happens when a Workflow Rule triggers by creating or editing a User record and also executes a Flow Trigger to manipulate records from other types of sObjects rather than the User record alone.  In particular, it happens when a Workflow tries to update one of these fields on the User record as well as other sObjects like Contact or Case:
  • UserRoleId
  • IsActive
  • ForecastEnabled
  • IsPortalEnabled
  • Username
  • ProfileId
Here are some techniquess to avoid encountering the Mixed DML Operation error message:
  1. Try using a different sObject, not the User record, for Workflow Rules and Flow Triggers if you encounter the error regardless of which fields are being updated.  
  2. To update the six standard fields listed above, create two different Workflow Rules, for example:
    • Initiate the first Workflow Rule off a record other than the User record.  Use this other sOject to trigger updates to custom fields on the User record for any of the above six  fields.  You can operate User custom fields safely alongside data from other sObject records in a single workflow.  
    • A second, time-based Workflow Rule can operate on the User record alone and update the above fields based on changes to your custom versions of those fields.  This Workflow Rule only operated as a time-based trigger and only allows for field updates on the User record.  Note: do not check the box on your User-based Workflow Rule that calls for all workflows to be reevaluated.  If that box is checked, you may experience the DML error again.
  3. If you don't want to run two separate Workflow rules and must manipulate one of the User fields based on changes to the User record, don't do it in a Workflow.  Instead, create a Visualforce page to call the Flow and create a custom link on the User detail page to access the page and Flow.  Click here for information about passing record IDs to a Flow with Visualforce.  The Flow will manage each data manipulation request as a separate transaction if it is not called by a Workflow and so the Mixed DML error should not occur.
Using one of these techniques with Flow Triggers can avoid the problem of having a trigger fail to execute a flow due to mixed data manipulation errors.
 

Monday, December 9, 2013

User Interface Improvements With Salesforce Flow

Flow gives administrators the opportunity to offer users a custom interface for interacting with Salesforce providing as much help as you think they may need to get their jobs done, from simplifying data entry to providing insight to help users complete forms, all without the need for code.

Last week, I defined some use cases for Flow and offered a presentation to introduce you to various features of Flows for data input and Salesforce record creation.  This week we look at ways to improve the user experience with Flows.

You can access the demonstration Flow I created at http://flow.snugsfbay.com.

Help

CSS and HTML
Cascading Stylesheets offer control.
Each Flow Screen has its own Help Text area, which you can use to add an extra bit of information  that may not be needed by all users.  In my example Flow, the lead form Screen includes a link to Help, located with the "Next" and "Previous" buttons, to let users know that their information will not be shared.  Other Screens offer more in-depth information in their Help.  And Screens that don't have Help text do not show a link at all.

Because Help text is defined per Screen, your Flow can provide context-sensitive help to your users.

Branding & Style

Flows offer two ways to format output display text and Help text.  Toggling to the Rich Text Editor while editing text, you can select formatting option buttons for bold, italics, font, etc.  But you can also enter HTML tags directly without toggling to the Rich Text Editor.  For example, "Not Bold and <b>Bold</b>"  will display the following: 
Not Bold and Bold

You can also use HTML tags to add an image directly to your Flow.  For example, adding the following to display text will display the Bay Area Nonprofit User Group logo: "<IMG SRC="https://c.na14.content.force.com/servlet/servlet.ImageServer?id=015d0000001wpuy&oid=00Dd0000000gNhq&lastMod=1381177979000" WIDTH="100" ALT="SNUGSFBay">"

For even more control over the look and feel of your Flow, define a cascading stylesheet (CSS) and incorporate both the Flow and CSS into a Visualforce page.  Among the tags particular to Flow are FlowContainer and FlowPageBlockBtns.

Special Tip

One undocumented CSS tag that you will want to know about if you change the background color of your Flow is interviewFormHeaderCell.  If you see a random underline character at the top of every Flow Screen, it comes from a bit of code automatically inserted by Salesforce, and is a known bug.  To get rid of the stray text use the following code in your Visualforce page or adapt it for your CSS file:

        
    <STYLE type="text/css">
        .interviewFormHeaderCell {border-bottom:0px;}
    </STYLE> 

According to technical support, this is the only way to get rid of the unwanted character as of Dec. 9, 2013.

Next week's blog post will describe some of the more complex data handling options currently available with Salesforce Flow.