A couple of “light code” options for you – continued…
Option 2
Add one or more controls – this example uses two Text Boxes – to allow user to enter filter values. Add a Button that will execute the BAQ and through the magic of BAQ Markup, the filter values will be applied to the BAQ as specified in the BAQ Criteria.
BAQ Markup (in my opinion) is relatively unknown and little understood and yet for some UI specific purposes, it is really powerful. BAQ Markup was introduced in 9.05 for InfoZones and has since expanded to BAQ Combos and optionally to programmatically executed BAQs – which is what is being done here. BAQ Markup is a reference to data in the UI and the referenced data will be “substituted” at runtime for the Markup. In this example, the Markup is referencing a specific Epibinding and the Markup will be replaced with the data in the UI for BAQ execution. BAQ Markup (as a concept) is actually pretty well documented in newer versions.
Pros - not much code; Pretty simple setup; allows BAQ level where clause filtering without pop-up prompt and with full control of Criteria condition (Equal, Greater than, Begins, etc.) and also full control of And / Or condition linking
Cons – Requires that All BAQ Markup applied filters have a Filter value entered in the UI; Standard DBD Refresh will return no records (you might want to remove the Toolbar Tool or hi-jack the click event)
My Specific setup - use as example for your use case:
BAQ called “DemandSearch” created against the Customer table with BAQ Markup applied in the Table Criteria against the CustID and City columns (not particularly useful except for as a simple example)
On the “Table Criteria” Sheet of the BAQ Designer, create two criteria lines:
Field: “CustID” Operation: “Begins” Filter value: “specified Constant” for the specified part enter: [Epibinding: CallContextBpmData.Character01]
And
Field: “City” Operation: “Begins” Filter value: “specified Constant” for the specified part enter: [Epibinding: CallContextBpmData.Character02]
An image of my sample BAQ is below.
DBD created with DemandSearch BAQ. Tracker Panel added - No Fields set as Prompt
DBD AppBuilt and added to menu
Run DBD from Menu in Customization Mode. Customize:
Add TextBox control for CustID filter – bind to CallContextBpmData.Character01
Add TextBox control for City filter – bind to CallContextBpmData.Character02
Add Button control - Set Text to “Refresh”
On Event Wizard - Add “Click” Event for Refresh Button
Add Code via Script Editor:
Line of C# added for Click event. As referenced in Option 1, OnSearch has three parameters leave the first two parameters set to an empty string and set the third parameter to true. The third parameter tells the OnSearch method to handle Markup substitution. While this Option uses Markup and the first Option used Criteria Injection, the two are not mutually exclusive and you could use both techniques together.
Not added for this Sample but something you would want to do – Add Row rule to Disable the “Refresh” button until all Markup referenced filters have a value – Bind the Button to something like BpmData.Character10 and enable and disable via that data reference.
Good to know:
If there is no data in the Markup Referenced field, the Markup itself is sent as the Where Clause Criteria – clearly not useful…
You cannot Test Markup in the BAQ Designer - it just executes the BAQ with the Markup as the criteria. Test your BAQ without Markup and when happy, add the Markup criteria.
// Code Sample Pulled from Script Editor
public class Script
{
// ** Wizard Insert Location - Do Not Remove ‘Begin/End Wizard Added Module Level Variables’ Comments! **
// Begin Wizard Added Module Level Variables **
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
// End Wizard Added Custom Method Calls
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void epiButtonC1_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
// DemandSerch is the ID of the BAQ I am using. DemandSearch as in On Demand Search...
V_DemandSearch_1View_Row.OnSearch("","",true);
}
}