Mobile Workflow Native Device Functions

Access the native features of the device using the native device functions.

Method Description
setScreenTitle(screenKey, screenTitle) Sets the specified screen’s title based on its sup_screen_title attribute value.
  • screenKey – the screen.
  • (optional) screenTitle – an explicit screen title to use rather than the sup_screen_title attribute value.
closeWorkflow() Closes the Mobile Workflow application.
addMenuItem(menuItemName, functionName, subMenuName, screenToShow) Allows the user to add a native menu item with the specified name and with the specified callback, which is invoked when the menu item is clicked.
  • menuItemName – the specified menu item name.
  • functionName – the specified callback name.
  • (optional) subMenuName – the specific submenu name for Windows Mobile platforms.
  • screenToShow – the screen that is about to be shown. This is an optional parameter; if it is not supplied, it is assumed that you are adding the menu item to current screen.
removeAllMenuItems() Removes all native menu items.
Note: Removes all menu items from the current screen. On iOS devices, all the menu buttons on the header and footer bars are removed. On Blackberry and Android devices, all native menus are removed. It is recommended that this method be called from customAfterShowScreen.
clearCache() Allows the user to clear the contents of the on-device request result cache for the current workflow.
clearCacheItem(cacheKey) Allows the user to clear an item from the contents of the on-device request result cache for the current Mobile Workflow form.

cacheKey – the key for the item to be removed. See the Workflow.js file for details on how to construct this.

Note: This function is for the "Online Request" cache only and does not apply to cached credentials.
logToWorkflow(message, level, notifyUser) Allows the user to log a message to the device trace log, which can be remotely retrieved from the server.
  • message – message to log.
  • level – level at which to log (ERROR, WARN, INFO, or DEBUG).
  • notifyUser – if true, an alert dialog is shown before logging commences.
showCertificatePicker() Opens a form on the device that allows the user to specify the credentials through the use of certificate-based authentication.
showUrlInBrowser(url) Open the supplied URL in the browser.
Use this method only for opening external HTML files. To open a local HTML file, you must add an HtmlView control to the screen and use something similar to the following for the control's value:
<iframe src="./local_file_name.html" width="100%" height="80%">
<p>Your browser does not support iframes.</p>
</iframe>
showAttachmentContents(contents, mimeType, fileName) Shows the given file contents in a content-appropriate way. The content type is supplied by either the MIME type or the file name, at least one of which must be supplied. The content itself should be presented as a Base64-encoded string.
  • contents – the Base64-encoded version of the binary content of the attachment to show.
  • mimeType – (optional) the MIME type of the file.
  • fileName – (optional) the name of the file.
showAttachmentFromCache(uniqueKey, mimeType, fileName) Shows the given file contents in a content-appropriate way. The content type is supplied by either the MIME type or the file name, at least one of which must be supplied. The content itself is a unique key supplied earlier to a call to doOnlineRequest.
  • uniqueKey – the unique key for the attachment.
  • (optional) mimeType – the MIME type of the file.
  • (optional) fileName – the name of the file.
showLocalAttachment(key) Shows a local attachment.

key – the key.

doOnlineRequest(screenKey, requestAction, timeout, cacheTimeout, errorMessage, errorCallback, workflowMessageToSend, cacheKey) Allows the user to cause an operation/object query to be invoked.
  • screenKey – the specified screen on which the submit is occurring.
  • requestAction – the specified action for the submit.
  • timeout – specifies the time, in seconds, to wait for a response.
  • cacheTimeout – specifies the time, in seconds, since the last invocation with the same input parameter values, to use the same response as previously retrieved without making a new call to the server.
  • errorMessage – specifies the string to show if an online request fails.
  • errorCallback – name of the function to be called if an online request fails.
  • workflowMessageToSend – Mobile Workflow message that is sent as the input in an online request.
  • cacheKey – string used as the key for this request in the on-device request result cache.
doAttachmentDownload(screenKey, requestAction, workflowMessageToSend, attachmentKey, requestGUID, downloadCompleteCallback)
  • screenKey – the specified screen on which the submit is occurring.
  • requestAction – the specified action for the submit.
  • workflowMessageToSend – the Mobile Workflow message that is sent as the input in an online request.
  • attachmentKey – the specified key of the result is not returned in the workflow message but is, instead, stored on the device for later access.
  • requestGUID – if specified, represents a unique key that can be used to store/access the cached key value from the request results. Must be specified if keyToCache is specified. Used to support attachments.
  • downloadCompleteCallback – if specified, is a function that is invoked when the cached value has been downloaded to the device and is ready to be accessed. Must be specified if keyToCache is specified. Used to support attachments.
doSubmitWorkflow(screenKey, requestAction, submitMessage, resubmitMessage) Allows the user to cause an operation/object query to be invoked. Will close the workflow application when finished.
  • screenKey – the specified screen on which the submit is occurring.
  • requestAction – the specified action for the submit.
  • submitMessage – specifies the string to show if an asynchronous request is successfully submitted.
  • resubmitMessage – specifies the string to show if an asynchronous request is not submitted because the workflow has already been processed.
showAlertDialog(message, title) Brings up a message dialog with the specified message, or, optionally, on iOS only, the specified title.
showConfirmDialog(message, title) Shows a confirmation dialog.

showUrlInBrowser(url)

To have a hyperlink in the default value for the HtmlView control, or for doing customization in Javascript, follow the showUrlInBrowser method without using standard HTML. To add HTML in the default value for the HtmlView control, you can use something similar to:
<html>
<body>
<b>Welcome to Sybase Mobile Workflow</b><br>
<br>Your activation was successful, the newly created Workflow requests will automatically be pushed to you.<br>
<br>For more information contact your administrator or visit us at:<br>
<br>
<a href="javascript:showUrlInBrowser('http://www.sybase.com/
unwiredenterprise')">The Unwired Enterprise</a>
</body>
</html>

Example 2

View an attachment such as an image, a Word document, a .pdf file, and so on as part of the Mobile Workflow package. This example uses an image file.
  1. Generate the Mobile Workflow package and its files.
  2. In WorkSpace Navigator, go to the location where the generated Mobile Workflow files are located and add an images folder under the html folder, for example, Generated Workflow\<Workflow_name>\html\images.
  3. Copy an image to the images folder.
  4. In the Mobile Workflow Forms editor, add a menu item to the Mobile Workflow.
  5. Open the Custom.js file with a text editor and edit the method customBeforeMenuItemClick:
    if (screen === "ScreenKeyName" && menuItem === "ShowAttachment") {
    	showLocalAttachment("html/images/ipod.jpg");
            return false;
        }
    
  6. Save and close the Custom.js file.
  7. Deploy the Mobile Workflow package to Unwired Server.