Showing posts with label Actions. Show all posts
Showing posts with label Actions. Show all posts

Sunday, July 13, 2014

Leveraging List Views With Salesforce1

The good thing about Salesforce1 is that you have to rethink your user experience and data access for mobile.  Yes, I said good thing because rethinking data access with the mobile user in mind will result in a better user experience for someone on the road than shoehorning everything from the desktop onto a more limited device would.  With Salesforce1, you can provide mobile users with access to data specific to their needs while on the road thanks to Flexipages.

Try something different just for mobile users.
A local nonprofit where I occasionally do volunteer Salesforce development work wanted a mobile app to provide users with quick access to specific groups of records.  These users need to update about 200 or more records a day using a mobile device.  And they want some flexibility regarding the order in which these records might be accessed.

My first thought was to create Visualforce pages that would offer specific groupings of records, but the nonprofit really needed something more flexible.

So I turned to Flexipages to solve the problem.  With Flexipages, you can design a mobile-specific interface that relies on List Views to provide access to specific groups of data.

At their most basic, Flexipages simply define which List Views for a specific object should be incorporated into the mobile experience, including the Recent Items list.  If you can create a List View that prioritizes Accounts Needing Attention, for example, the mobile user can bypass the Accounts Tab and just access that list with a Flexipage.

But Flexipages don't merely offer a single List View, they can combine multiple List Views and Global Actions all in the same screen.  So a Flexipage might offer access to Accounts Needing Attention and Currently Discounted Products all with a single navigation graphic, in addition to a Global Action for creating a New Contact.

In crafting a mobile experience for your users, consider creating Flexipages and putting them at the top of the navigation menu, above the standard tab navigation options like Account and Contact Tabs.  This gives  users more immediate access to specific records of interest to users on the go.

For the nonprofit, I created several new List Views to combine different records on the same page.  I also added an image formula to signify which records had been updated on the road to help the user easily determine which records still needed attention.  You can read more about using images with Flexipages in a recent post.  I also created about 10 different Flexipages to provide the most flexible access to all the records they update via mobile.

Flexipages are easy to create as text files outside of Salesforce.  They are XML files, which are simply text files with specific textual "tags" enclosed in triangular brackets.  For example, "<description>" is a beginning tag and "</description>" as an ending tag, while the text between these two tags would be the actual description.

Once you create a Flexipage, the easy option for deploying them, currently, requires placing them in a zip file with a particular directory structure and naming convention, and including a second XML file listing which Flexipages to deploy.  The zip file can be deployed with Salesforce Workbench using Migration>Deploy.

For more information about creating Flexipages, refer to the documentation here: http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_flexipage.htm

Once you consider which data is the highest priority for mobile users, simple List Views, combined with Flexipages, provide the view your mobile user needs to the data they most want.


Tuesday, July 1, 2014

Think Like a Developer When You Design Flows

Flows offer a lot of power to clicks-not-code administrators who want to automate processes using record lookup, update and create options offered with this easy-to-use feature.  Of course, Flows do require that administrators learn to think like developers a bit.  They must be able to outline the process the Flow should take, including decision points where the flow might go in one of multiple directions.  They must also think of ways to test and debug their Flows and to create Flows that can be reused or called in multiple ways.
You need to know how to look for bugs in your Flow.

Test Extremes

One rule of testing is to keep in mind the extremes and the improbable.  What happens when users enter data that is out of scope, or when a record that the Flow expected to exist (like a generic, default Account record) has incorrectly been deleted.  Make sure your Flow includes fail-safe procedures and uses error messages, which Flow makes available, to catch these situations.

Break Points and System.Debug

As you are developing your Flow, be liberal with Screens to display the values of variables along the different Flow paths.  One of the things I love most about Flows is the ability to create Screens that I do not tie into the Flow.  This enables me to create break points that halt the Flow before the error occurs and lets me display debug messages for myself between steps, providing the values of variables needed in subsequent steps.  When the Flow is ready to be activated for users, I can first disconnect all of the extra Screens and leave them in the Flow if there is a chance I will need to rework the Flow.

For example, between the record lookup step that assigns data to variables and the decision branch step where the Flow's path will be determined according to variable data, I will create a Screen to display the record ID and all of its variable data.  I won't bother to connect the Screen unless I find that the decision branch does not behave the way I expected.  I can even leave the Screen in place to use as in future versions of the Flow or to use later, when the data model defined with Salesforce objects and fields may have changed (the 'model' part of the Flow).  Otherwise, the Screen stays disconnected from the Flow.

Flow Triggers

For Flows to be used with Workflow rules, they are expected to operate without a user and so trigger-ready Flows cannot have Screens, which require a Flow user to click the 'Next' button to proceed.  This can complicate the debugging process, but don't be discouraged.  When you are first creating a complicated flow, you can still use Screens and simply call the Flow from a link or, to easily pass parameters, a Visualforce page.  See my earlier post for more information about calling a Flow from Visualforce.  Keep in mind that trigger-ready Flows cannot include Screens with error messages and so should be thoroughly tested outside of the workflow rule, to work out ways to avoid errors during the Flow execution.


Deleting the leftmost and rightmost columns
makes this Flow trigger-ready without Screens

Design Patterns

Converting a working Flow that has been created with Screens to one that is trigger-ready and without Screens is easy if you just employ a simple design pattern.  For my Flows, I keep the data and logic elements like decision branches and record manipulation, which you could call the 'controller' or core part of the Flow, in a vertical path down the center of my design.  For the Screens, which you could call the 'view' part of the Flow since that is the part Flow users can see, I push those elements out into columns to the far left and far right of my controller elements.  For example, a simple Flow would have two columns, the leftmost would be Screens only, the rightmost would be logic and record manipulation only.  A more complicated Flow might have Screens on both the rightmost and leftmost columns, like the one illustrated here.

By keeping Screens in their own columns away from the logic, they can be quickly selected within the Flow designer with a single motion and deleted from the design  when you are satisfied with the functionality so that the Flow can be used as part of a workflow without user intervention.

Flows can be executed by Visualforce pages, by other Flows, and by users; with Summer '14 Apex will be able to execute Flows as well.  They can be executed  from record detail pages using buttons, links and Actions; from Tabs, Force.com Site pages and from Global Actions.  Keeping the Flows small and function-specific will help make them reusable in these many scenarios so that you don't have to recreate the same functionality in multiple Flows.  For example, a Flow that operates from a workflow rule and also from an Action on a record detail page might have the 'controller' elements in one Flow that can be called by a Flow Trigger as well as by a Visualforce page that would provide some 'view' context for the user executing the record Action.

Even clicks-not-code administrators can be creative developers once they start designing for multiple uses and considering the debugging process and Model-View-Controller implementation patterns.  And as you become more comfortable thinking like a developer, you may eventually decide to learn more about the Debug Logs and Developer Console.  But with Flow, you might even decide you don't need those to create complex business solutions that work well for your users.