Creating a Part Search for BAQ

Since you are just on a dashboard, that’s exactly what you want to do, remove the parameter.
Use only the tracker. Trackers DO send a where clause in the query. The filtering is not
done locally. It will not be insanely slow, unless you are doing something very complex with
your parameter.

Reference:


So now let’s say you do that.
You now have a tracker field called “Part Number”.
Set it to “StartsWith”, and just use the first part of the parameter.
Or “Matches(or is it Contains?)” and you can use it like this:
“mypartnum” matches “SomeTextmypartnumSomeText”
“%mypartnum%” matches “SomeTextmypartnumSomeText”
“%mypartnum” matches “SomeTextmypartnum” (Ends With)
“mypartnum%” matches “mypartnumSomeText” (Starts With)

To get your value from the part search, you will need to get a reference
to your textbox from the tracker.

Add a TextBox variable inside the Script class like so:
Get a reference to the tracker textbox in the Initialize Custom Code Method
In the PartSearch Click Event, populate your textbox.

using System.Collections;

public class Script
{
    // Add Custom Module Level Variables Here **

    //TextBox Variable
    EpiTextBox myPartSearchTextBoxIsSoFancy = null;

    public void InitializeCustomCode()
    {
        this.PartSearch.Click += new System.EventHandler(this.PartSearch_Click);

        //Get Reference from PartNum TextBox on Tracker
        myPartSearchTextBoxIsSoFancy = (EpiTextBox)csm.GetNativeControlReference("theGUIDofYourTextBox"); //Get GUID from properties on form
    }

    public void DestroyCustomCode()
    {
        this.PartSearch.Click -= new System.EventHandler(this.PartSearch_Click);
    }

    private void PartSearch_Click(object sender, System.EventArgs args)
    {
        //Changed multiselect to false
        object ret = ProcessCaller.InvokeAdapterMethod
            (oTrans.EpiBaseForm, "QuickSearchAdapter", "ShowQuickSearchForm", new object[] 
            {oTrans.EpiBaseForm, "PartSearch", false/* multi-select */, new DataTable() });

        // user cancelled
        if (ret == null) return; //This is a short circuit. If no value was returned, exit method.			
        ArrayList list = (ArrayList)ret;

        //Not sure on syntax, don't use ArrayList often
        if(list.Count() > 0)
        {
            myPartSearchTextBoxIsSoFancy.Text = list[0];
        }
    }
}

Press refresh and you’re done.