Allow Parameterization XMMobile

How Can We Help?

Allow Parameterization XMMobile

< Back

Scenarios

There is a first activity actionable from XMMobile that displays a list of data in an object group. The list of data displays basic information of the data entity. The requirement is for the user to be able to click on a link in a particular row of data and navigate to an activity which, either displays additional data relevant to the row selected or gives the ability to amend the specified data. To allow for this to occur the data row in the object group needs to have a link that navigates to a specified activity defined in XMPro, included in the link is a parameter name (Name of Control) and value which the system will then use to populate the relevant fields in the activity.

Problem Description

XMMobile currently does not support the Allow Parameterization functionality that is available in XMWorkspace through a setting from within the XMDesigner.

Solution

In order to achieve the same functionality, the following steps should be followed:

Step 1 – JavaScript file

In the XMMobile website navigate to the following folder “..\XMMobile\Scripts\Custom” and create or add to the file custom.js the following JavaScript:

$(document).on(“pageshow”, function (e) { getUrlVars(); }
function getUrlVars()
{
var hash;
var hashes = window.location.href.slice(window.location.href.indexOf(‘?’) + 1).split(‘&’);
strCTN = ”;
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split(‘=’);
if ($(‘#’+hash[0]).length > 0) { $(‘#’+hash[0]).val(hash[1]); if ($(‘#’+hash[0]).hasClass(“PostBack”)) { strCTN = hash[0]; } }
}
$(‘#’ + strCTN).trigger(‘change’);
}

Step 2 – XMPro textbox control

The purpose of the javascript above once added to the XMMobile website and the custom.js file is to look for any parameters in the page URL that have the same name as a field within the XMPro activity if the name of the parameter is found in the XMPro activity the parameter value will be passed through to the XMPro field. So in order to get this working you will need to create a simple text box to receive the value passed into the activity. It is important to understand that the JavaScript above will only function as expected with a simple text box. The simple text box must also be kept visible (visible=true) so that XMPro creates the html field element for use by the JavaScript.

(Note: To make the field appear invisible then the Caption can be removed and the display:none; style option can be added to Options->Style from within the XMDesigner)

Step 3 – Link to XMPro Activity

Once you have added the JavaScript to the custom.js file as well as created the simple text box to receive the parameter value. You will need to make sure that the link being used to click through to the detail activity needs to include the following:

–          The parameter, this will be the simple textbox name, and

–          The value, this will be the value of the parameter you will send through

An example of the URL with parameterization is as follows:

http://xmserver/Website/ProcessItem.aspx?g=17&id=5&AC1010ControlName=ValuePassedThrough

where AC1010ControlName is the name of the control in the activity being opened and the ValuePassedThrough is the value that will be set for the Control specified.

Other:

It is important to understand that the JavaScript populates the field after the activity onload has occurred. This means that if you rely on information to be populated or sql queries to be run onload, so that data is available for the user to view without having to take action to view the information, then you will need to set the AutoPostBack option on the control receiving the value to True. This will allow the JavaScript above to call a postback which will trigger the activity OnRefresh methods to retrieve and therefore display the required information.

Comments are closed.

This is the legacy version of the XMPro Documentation site. For the latest XMPro documentation, please visit documentation.xmpro.com

X