Category Archives: Visual Workflow

First Looks at Visual Workflows

From what I have seen so far Visual Workflows are designed to be used by Administrators without coding knowledge or experience. It is similar to Workflows. Workflows enable workflow rules to be set up that identify record changes that trigger workflow actions whereas Visual Workflows allow flows to be created that are applications that are user-triggered instead of event-triggered.
Downsides
Errors:
Errors are handled with an error message that simply says:

“An unhandled fault has occurred in this flow. Please contact your system administrator for more information. “.

It will send an email to you with more specific information on the exact error. An example that I received:

Encountered unhandled fault when running process eFNOL/301c00000008pFw exception by user/organization: 00Dc0000003tkkJ/{4} Source organization: 00DE0000000f0YX (null) ; nested exception is: 
    common.exception.ApiQueryException: 
Unit__c.Id FROM Unit__c WHERE (Unit__c.PolicyNumber__c = 'Varnson
                               ^
ERROR at Row:1:Column:39
invalid ID field: Varnson Policy 1
(There was a problem executing your command.) > RETRIEVE

caused by element : FlowRecordLookup.Unit_Lookup

caused by: ; nested exception is: 
	common.exception.ApiQueryException: 
Unit__c.Id FROM Unit__c WHERE (Unit__c.PolicyNumber__c = 'Varnson
                               ^
ERROR at Row:1:Column:39
invalid ID field: Varnson Policy 1
(There was a problem executing your command.) > RETRIEVE

Salesforce Error ID: 1170913603-43025 (-1680723869)

These emails point out exactly where the error occurred making it easy to fix but unfortunately, if I were to go back and fix this error, run the flow again and get another of the error handling messages from a different process, I wouldn’t get another email regarding the new error. To help with errors, I put debugging screens in between steps that would be passing variables to track the steps one at a time to see where errors were occurring.
UI

The only way to adjust the user interface (using css for example) is to embed the flow into a Visualforce page. That is done by adding the tag somewhere between the elements. This adds another level of security concerns: any user that can access the Visualforce page can also run the embedded flow. Internal users also will need the “Run Flows” permission. All this really does is add an additional step to the page and an additional set of code to be maintained when the page can be set up as a flow by itself. This is what it looks like:

flow1

When this is what we wanted:
flow2

 

Documents

The only way to add a document upload process to a Visual Workflow is to create a custom Apex class that behaves as a controller for a Visualforce page that references it. This is the same as the UI situation in that it requires extra code to write and maintain when the page can do that work by itself.

Development
I spent way too much time debugging a strange error that I was getting when running the flow that I set up. For the life of me I could not figure out why the error was occurring and since it wasn’t my first error (see above error reporting) I wasn’t receiving an email that pointed out the problem. Then I finally figured it out when I brought up the Schema Builder which pointed out a curiosity in the Field Information on the object:

 

flow3

 

 

When accessing fields and their data from the Flow Designer, the API Name is what is used. I was trying to reference what I thought was a number when it was actually a reference to another object. Unlike an IDE like Eclipse, the Flow Designer doesn’t send up alerts for errors like this.

Upsides

Versions
You can have several different versions of a single flow (but only one version of each flow can be active at a time).
Flow Designer
The user interface is very easy to use. It has all the components and resources that can be dragged and dropped onto the canvas. It is easy to create and edit custom variables.

Store Multiple Values Together in a Flow

Store multiple values together—so that you can operate on them—by using the new collection variable flow resource. Collection variables can store both manually entered values and values from flow resources, such as email addresses entered in a flow’s screen. Using collection variables can help you conserve limits by not querying the Salesforce database for that information.

Previously, you couldn’t store manually entered values or values from another flow resource. Both sObject variables and sObject collection variables can store multiple values, but they must be field values.

Create a collection variable from the Resources tab in the Cloud Flow Designer by double-clicking Collection Variable.

Unlike with variables, sObject variables, and sObject collection variables, you can’t use Record Lookup or Fast Lookup elements to populate a collection variable. To populate a collection variable, add values whose data type matches the collection variable by using an Assignment. In other words, don’t try to add a variable of type Text to a collection variable of type Number.forcecom_process_collvar