Workflow UI Functions

Functions that allow you to access the Mobile Workflow user interface (UI).

The Mobile Workflow UI functions are synchronous.
Method Description
getCurrentScreen() Returns the key of the current (open) screen.
setCurrentScreen(screenKey) Sets the value of the current (open) screen.
Note: This does not open the specified screen—this function is called only after the screen has already been opened.
getPreviousScreen() Returns the key of the screen that was open previous to the current screen being opened, if applicable.
getListViewKey(screenName) Returns the key of the first listview on the specified screen.

screenName – the specified screen.

navigateForward(screenKey, listviewKey) Navigates from the current (open) screen to a new screen with the specified key.
  • screenKey – the screen to open.
  • (optional) listViewKey – the listview row for which the details screen is being opened.
navigateBack(isCancelled) Closes the current screen and returns to the previous screen, if applicable. If the specified parameter value is false, the values on the open screen are persisted to the Mobile Workflow message if they pass validation.

isCancelled – true for a Cancel action, false for a Save action.

updateUIFromMessageValueCollection(screenName, values) Updates the values of the controls on the given screen based on the contents of the specified MessageValueCollection. This function will rarely, if ever, need to be called.
  • screenName – the screen.
  • values – the message value collection.
updateMessageValueCollectionFromUI(values, screenName, keys, keyTypes, updateModifiedValue) Updates the contents of the specified MessageValueCollection based on the values of the controls on the given screen. In most cases, saveScreen is called instead of this function.
  • screenName – the screen.
  • values – the message value collection.
  • (optional) keys – an array of keys, which is a list of only the keys to be updated.
  • (optional) keyTypes – an array of types for the list of keys, if supplied.
  • updateModifiedValue –
removeModifiedMessageValuesBasedOnCurrentScreen(values, screenName) Removes the modified contents of the specified MessageValueCollection. This function is called when a screen is cancelled.
  • screenName – the screen.
  • values – the message value collection.
saveScreen(values, screenKey, needsValidation) Saves the contents of the specified screen to the specified MessageValueCollection. This function differs from updateMessageValueCollection in these ways:
  • If directed, it first performs validation on the screen.
  • It supports customization.
  • It is capable of handling the credential request screen.
Parameters include:
  • values – the current message value collection.
  • screenKey – the current screen.
  • (optional) needsValidation – false if validation should not be done before saving, true (or unspecified) if validation should be done before saving. Returns true if saving (and validation, if requested) was successful, otherwise, returns false.
saveScreens(skipValidation) Saves the contents of all open screens if they are successfully validated.

skipValidation –

Example 1

updateUIFromMessageValueCollection

To completely override the behavior provided by updateUIFromMessageValueCollection for a given screen, provide a UIUpdateHandler object for that screen. That UIUpdateHandler object has a screenName property, which indicates which screen's behavior it is overriding, and a callback function that indicates the function to call for that screen. That function is passed in the relevant MessageValueCollection object and it is its responsibility to update the controls' values based on its contents. An example of this is:

function MyListViewUpdateHandler() {
	    this.screenName = "Prev_Expenses";
	    this.values;
	}

	MyListViewUpdateHandler.prototype.callback = function(valuesIn)  {
	    // Rows returned from RMI Call
	    this.values = valuesIn;

	    // construct our table
	    try  {
	        var mvc = this.values.getData("PurchaseTrackingJC_findOtherRequests_resultSetKey");
	        var txt = "";
	        var htmlOut = "<p>";

	        // Do we have any rows to display?
	        if (mvc.value.length > 0) {
	            // Start the table and header
	            htmlOut += "<table id='MyPrevExpensesTable' class='altrowstable'>";
	            htmlOut += "<tr><th>Item Name</th><th>Cost</th></tr>";
            
	            // Draw the rows+H15
	            for (var rows = 0; rows < mvc.value.length; rows++) {
	                var mvName = mvc.value[rows].getData("PurchaseTrackingJC_itemName_attribKey");
	                var mvCost = mvc.value[rows].getData("PurchaseTrackingJC_itemCost_attribKey");
                
	                if (mvName && mvCost) {
	                    // Alternate the row colors
	                    htmlOut += "<tr onclick='navigateForward(\"Prev_Expenses_Detail\", " + mvc.value[rows].getKey() + ");'";
	                    if (rows % 2 == 0) {
	                        htmlOut += " class='evenrowcolor'>";
	                    }
	                    else {
	                        htmlOut += " class='oddrowcolor'>";
	                    }
                    
	                    htmlOut += "<td>" + mvName.getValue() + "</td><td>" + mvCost.getValue(); +"</td></tr>";
	                }
	            }
            
	            // Finish the table
	           htmlOut += "</table>";
	        }    
	        else {
	            htmlOut += "No rows returned.";
	        }
	        htmlOut += "</p>";
        
	        //Now add the table to the document
	        var form = document.forms[curScreenKey + "Form"];
	        if (form) {
	            //var topOfFormElem = document.getElementById("topOf" + curScreenKey + "Form");
            
	            var topOfFormElem = document.getElementById("PurchaseTrackingJC_findOtherRequests_resultSetKey");
	            topOfFormElem.innerHTML = htmlOut;
	        }
	        
	    }
	    catch (e) {
	        alert(e.message);
	    }
	} // function callback

	function customAfterWorkflowLoad() {
	    //Setup UIHandler to draw our Listview Screen
	    UIUpdateHandlers[0] = new MyListViewUpdateHandler();
	}