Using C# solution to create reusable multi-select parameters in Blackbaud UI model
The multi-select paramteter will return a pipe delimited string of the selections Caption or Description field.
Ex. "Payment|Pledge|Recurring Gift"
The below steps outlines the steps used to create the transaction types multi-select parameter in the Example data list spec
These steps only need to be done once for each multi-select parameter
Create a CustomUI xml spec with a field for each option as a boolean data type and a string field for the delimited values
<FormFieldFieldID="Payment"Caption="Payment"DataType="Boolean" /> <FormFieldFieldID="Pledge"Caption="Pledge"DataType="Boolean" /> <FormFieldFieldID="RecurringGift"Caption="Recurring Gift"DataType="Boolean"/> <FormFieldFieldID="MatchingGift"Caption="Matching Gift"DataType="Boolean" /> <FormFieldFieldID="TransactionTypesDelimited"DataType="String" />
Add two actions
<UIActions> <UIActionActionID="SelectAll"Caption="Select all" /> <UIActionActionID="UnselectAll"Caption="Unselect all" /> </UIActions>
Create a Custom UI Model from the spec
In the code gen file create a global class member for a List<BooleanField>
privateglobal::System.Collections.Generic.List<BooleanField>_transactionTypes;
In the constructor method for the class add each field to the member
_transactionTypes=newglobal::System.Collections.Generic.List<BooleanField>();_transactionTypes.Add(this._payment);_transactionTypes.Add(this._pledge);_transactionTypes.Add(this._recurringgift);_transactionTypes.Add(this._matchinggift);
Adds methods for "select all" and "unselect all" actions. The UpdateAll method is in the solution already.
privatevoid_selectall_InvokeAction(objectsender,InvokeActionEventArgse){MultiSelectFunctions.UpdateAll(ref_transactionTypes,true);}privatevoid_unselectall_InvokeAction(objectsender,InvokeActionEventArgse){MultiSelectFunctions.UpdateAll(ref_transactionTypes,false);}
Add event handlers to the _Loaded method
// adds select all / unselect event handlersEventHandler<InvokeActionEventArgs>eventHandler1=newEventHandler<InvokeActionEventArgs>(this._selectall_InvokeAction);EventHandler<InvokeActionEventArgs>eventHandler2=newEventHandler<InvokeActionEventArgs>(this._unselectall_InvokeAction);this._selectall.InvokeAction+=eventHandler1;this._unselectall.InvokeAction+=eventHandler2;
Add method to form validated to create delimited string
privatevoid_form_validated(objectsender,Blackbaud.AppFx.UIModeling.Core.ValidatedEventArgse){this._transactiontypesdelimited.Value=MultiSelectFunctions.BuildPipeDelimitedString(_transactionTypes);}
Add event handlers to the _Loaded method
// adds form validated argumentsEventHandler<ValidatedEventArgs>eh3=newEventHandler<ValidatedEventArgs>(this._form_validated);this.Validated+=eh3;
Script for _Loaded to handle currently selected values when form is created
if(this._transactiontypesdelimited.Value!=null){foreach(stringtypeinthis._transactiontypesdelimited.Value.Split('|')){foreach(BooleanFieldbfinthis._transactionTypes){if(bf.Caption==type){bf.Value=true;}}}}
In the spec create UI fields for the parameter as a string and a value list to use as a selector
<FormFieldFieldID="transactiontypes"Caption="Transaction types"DataType="String"AvailableToClient="false" /> <FormFieldFieldID="transactiontypesselector"Caption="Transaction types"DefaultValueText="0"Required="true"Enable="False" > <ValueList> <Items> <Item> <Value>0</Value> <Label>All transaction types</Label> </Item> <Item> <Value>1</Value> <Label>Selected transaction types</Label> </Item> </Items> </ValueList> </FormField>
Add an action to show the custom UI form created above and link it
<UIActionActionID="ShowTransactionTypesForm"ImageKey="res:editsmall"AvailableToClient="false"> <ShowCustomFormLinkedFieldId="transactiontypes"> <ModelComponentAssemblyName="ReportingMultiSelect.UIModel.dll"ClassName="ReportingMultiSelect.UIModel.MultiSelectTransactionTypesUIModel" /> </ShowCustomForm> </UIAction>
Add methods to UI class for handle showing and confirming the form. These methods pass the string value between the two forms
privatevoid_showtransactiontypesform_CustomFormConfirmed(objectsender,Blackbaud.AppFx.UIModeling.Core.CustomFormConfirmedEventArgse){this._transactiontypes.Value=(string)e.Model.Fields["TRANSACTIONTYPESDELIMITED"].ValueObject;}privatevoid_showtransactiontypesform_ShowCustomForm(objectsender,Blackbaud.AppFx.UIModeling.Core.ShowCustomFormEventArgse){if(this._transactiontypes.Value!=null){e.Model.Fields["TRANSACTIONTYPESDELIMITED"].ValueObject=(object)this._transactiontypes.Value;}}privatevoid_transactiontypesselector_ValueChanged(objectsender,ValueChangedEventArgse){if(this._transactiontypesselector.Value==TRANSACTIONTYPESSELECTORS.AllTransactionTypes){this._transactiontypes.Value=null;this._showtransactiontypesform.Enabled=false;}else{this._showtransactiontypesform.Enabled=true;}}
Add event handlers to the UI actions
// adds event handler for confirming transaction types formEventHandler<CustomFormConfirmedEventArgs>eh=newEventHandler<CustomFormConfirmedEventArgs>(this._showtransactiontypesform_CustomFormConfirmed);_showtransactiontypesform.CustomFormConfirmed+=eh;// adds event handler for showing transaction types formEventHandler<ShowCustomFormEventArgs>eh2=newEventHandler<ShowCustomFormEventArgs>(this._showtransactiontypesform_ShowCustomForm);_showtransactiontypesform.InvokeAction+=eh2;// adds event handler for transaction types enablerEventHandler<ValueChangedEventArgs>eh3=newEventHandler<ValueChangedEventArgs>(this._transactiontypesselector_ValueChanged);_transactiontypesselector.ValueChanged+=eh3;
Create custom javascript action to handle enable/disable/auto-show for the form.
(function(c,d){vare,b,a;b="SHOWTRANSACTIONTYPESFORM";a=BBUI.forms.Utility;c.on("formupdated",function(h){vari,g,j,f;j=h.formUpdateResult;g=a.findActionInFormUpdateResult(j,b,d);if(g){if(g.enabled){i=e}}if(i){c.invokeAction(d,i)}})})();

