Perspectives - Different views of the same workflow
Compose Enterprise is going through a design update. The illustrations on this page might be of the old design, but the information is up to date. Thank you for your patience during this update!
Compose is equipped with functionality to display different views of the same form/workflow. By defining different perspectives, you can customize the respondent view for the same workflow for different gadgets, say PC, iPad, Mobile, PDF etc. This user guide is a continuation of the Views - Different views of the same form user guide for creating different views of a form. In this user guide, we’ll implement different form views into different perspectives (which is the view equivalent for workflows).
Head to the Settings section in the workflow builder of a workflow in which you’d like to have multiple perspectives. In the Perspectives section of the workflow properties panel, click Create to add another perspective.
Enter a name for the perspective and click OK. The new perspective will appear in the list of perspectives. Repeat this process if you’d like more perspectives.
Navigate to the Builder. Before we connect the perspectives to views in the form activity, we need to set a matching mechanism in the start point. This mechanism triggers the correct perspective for the correct gadget. In this example we’ll demonstrate how to set up a mobile view. Start by selecting the start point. In the start point properties you’ll see that you can change the default perspective settings. Leave it for now.
Under Alternative View Settings click Add perspective. Select a perspective from the list and click OK.
Select the newly added perspective from the list to reveal the User Agent Pattern and Layout/Skin property. In the User Agent Pattern window we enter a script for the aforementioned matching mechanism. For cellphones the script reads (see the bottom of the page for more scripts):
agent.text.contains('mobile')
Change the Layout/Skin if you want a specific skin design for the perspective.
Now we can select the form activity (which is connected to a form with multiple views, see the Views - Different views of the same form user guide). Head to the Alternative View Settings in the form properties and click Add Perspective.
Select the perspective you want to add as an alternative view and click OK.
Select the newly added perspective to reveal the View and Layout/Skin properties for the perspective. The View dropdown lists all the form views. Select the desired form view.
Specify the skin and layout of the form view in the Layout/Skin dropdown.
Remember to save the draft and create a version to set the perspectives into effect.
User Agent Pattern Scripts
User agent pattern scripts must be specified for an alternative perspective of a workflow entry point to match the desired user agent (browser, tablet, mobile etc.). If the script returns true, then that alternative perspective is selected. Returning any other value or a failure of the script will result in that alternative perspective not being selected.
Following are the properties available to a user agent detection script.
Property | Description |
agent | Represents user agent information sent from the browser. |
Sample user agent string sent from the browser:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0
The user agent string is broken down into a list of items and exposed via the agent variable inside scripts. agent.items would return these items inside the scripts. An item can either be a product or a comment.
Product | Mozilla/5.0 | Contains name of a product along with the version. |
Comment | (Windows NT 6.1; WOW64; rv:11.0) | This is a comment having multiple details. Details are Windows NT 6.1, WOW64, rv11.0. Comments are housed inside () notation. |
Product and comment Objects expose properties to easily work with user agent string components.
Given below are some example scripts:
Test if the browser belongs to the Firefox family of browsers and its version is 11.0:
agent.items.text.contains('Firefox/11.0')
Test if the browser type Mozilla is of a version greater than 3: (Note that IE also sends the user agent as Mozilla)
agent.items.any {
it instanceof Product && it.name == 'Mozilla' && it.version.toDouble() > 3
}
Tests whether WOW64 is contained as a comment:
agent.items.any {it instanceof Comment && it.details.contains('WOW64')}
Tests whether Windows is contained as a comment (which determines that the user came from a Windows platform):
agent.items.any {it instanceof Comment && it.text.contains('Windows')}
Without operating on comments/products, it tests if the browser is IE:
agent.text.contains('MSIE')