Skip to content

Repository files navigation

Multi Select Parameters in Blackbaud CRM

Using C# solution to create reusable multi-select parameters in Blackbaud UI model

Alt text

Alt text

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

Steps to creating parameter

These steps only need to be done once for each multi-select parameter

  1. 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" />
  2. Add two actions

    <UIActions>
    <UIActionActionID="SelectAll"Caption="Select all" />
    <UIActionActionID="UnselectAll"Caption="Unselect all" />
    </UIActions>
  3. Create a Custom UI Model from the spec

  4. In the code gen file create a global class member for a List<BooleanField>

    privateglobal::System.Collections.Generic.List<BooleanField>_transactionTypes;
  5. 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);
  6. 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;
  7. 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;
  8. 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;}}}}

Steps to use parameters

  1. 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>
  2. 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>
  3. 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;}}
  4. 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;
  5. 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)}})})();

About

Steps to create multi-select parameters in Blackbaud CRM

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages