MultiSelect Picklists in SLX Mobile (v1.1)
Posted By: Alex.Cottner on June 27th, 2012 in General
No Gravatar

This was a recent┬ácustomization┬áthat I had to create for a client. They wanted to have multiselect picklists in their SalesLogix Mobile Client (v1.1). After poking around it didn’t look like Sage’s picklist control would handle it, so I modified it. Now all I need to do to use it is set a flag on the picklist control…

{
dependsOn: 'Type',
label: this.regardingText,
name: 'Description',
multiSelect: true,
picklist: this.formatPicklistForType.createDelegate(
this, ['Description'], true
),
title: this.activityDescriptionTitleText,
orderBy: 'text asc',
type: 'picklist',
maxTextLength: 64,
validator: Mobile.SalesLogix.Validator.exceedsMaxTextLength
}

Adding this functionality to the Mobile 1.1 picklist control was surprisingly easy. I’m not sure why Sage didn’t include it in the stock application. Below is what I added…

First, add the multiSelect flag to the object properties list.
multiSelect: false,

Next, modify the navigateToListView method by adding this line after the options are declared. This tells the list view to allow multiple selections to be made.
options.singleSelect = !this.multiSelect;

Last, override the complete function (PickListField just extends the LookupField) with this one.
complete: function() {
var view = App.getActiveView();
var success;
if (view && view.selectionModel)
{
var selections = view.selectionModel.getSelections();
var text = "";
var val = "";
for (var selectionKey in selections)
{
val += selections[selectionKey].data[this.keyProperty] + ", ";
text += selections[selectionKey].data.text + ", ";
success = true;
}
text = text.substr(0, val.length-2);
val = val.substr(0, val.length-2);
this.currentSelection = val;
this.currentValue = {
key: val,
text: text
};
this.setText(text);
ReUI.back();
if (success) setTimeout(this.onChange.createDelegate(this), 0);
}
}

And there you go, now you’ve got a multiselect picklist control on the mobile client.


Leave a Reply