# Passing Parameter/Filter in Dynamic Query

**URL:** <https://www.epiusers.help/t/passing-parameter-filter-in-dynamic-query/46665>\
**Category:** Epicor ERP 10\
**Created:** [August 6, 2018, 3:49pm UTC](https://www.epiusers.help/t/passing-parameter-filter-in-dynamic-query/46665 "2018-08-06T15:49:49Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![mchernecki](https://www.epiusers.help/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@mchernecki](https://www.epiusers.help/u/mchernecki)\
**Post date:** [August 15, 2018, 8:40pm UTC](https://www.epiusers.help/t/passing-parameter-filter-in-dynamic-query/46665/22 "2018-08-15T20:40:28Z")

</div>

> [@dhewi](#):
>
> Just to clarify, the method I was outlining is a lot of code, but it does do exactly what you want. We’ve standardised a lot of it to do what we need and now build most of our dashboards this way because it turns out to be more flexible and maintainable in the long run.
> 
> Step 1. Build and deploy a dashboard with a near-empty dummy BAQ, no grid view and one full-screen tracker view with no fields. That gives you a blank canvas.
> 
> Step 2. Create a customization for the blank dashboard. Use the standard tools to put an EpiUltraGrid where the grid would have been if you’d built the dashboard normally, and whatever other controls (eg an EpiTextBox) you want to put the parameters into. Add Assembly references for DynamicQuery.
> 
> Step 3. In the Script, put some variant of the following code:
> 
> ```
> DynamicQueryAdapter yourbaq = new DynamicQueryAdapter(this.oTrans);
> DataTable results;
> yourbaq.BOConnect();
> string baqname = "BAQNAME";
> Ice.BO.QueryExecutionDataSet dsBAQ = yourbaq.GetQueryExecutionParametersByID(baqname);
> dsBAQ.ExecutionParameter[0].ParameterID = "YOURPARAMETERNAME";
> dsBAQ.ExecutionParameter[0].IsEmpty = false;
> dsBAQ.ExecutionParameter[0].ParameterValue = VALUE FROM YOUR CONTROL AS A STRING;
> dsBAQ.AcceptChanges();
> yourbaq.ExecuteByID(baqname, dsBAQ);
> if (yourbaq.QueryResults != null && yourbaq.QueryResults.Tables.Count > 0)
> {
> results = yourbaq.QueryResults.Tables["Results"];
> }
> else
> {
> results = new DataTable();
> }
> EpiDataView edv = (EpiDataView)oTrans.EpiDataViews[baqName];
> if (!(edv != null))
> {
> edv = new EpiDataView();
> oTrans.Add(baqName, edv);
> }
> edv.dataView = results.DefaultView;
> 
> ```
> 
> Step 4. You can use the new EpiDataView to bind to your grid. If you close and open the screen (assuming you’ve put the above somewhere that runs on opening) then you’ll even find the dataview is available in the normal properties to use. I prefer to bind the grid’s DataSource rather than use EpiBinding myself, because it’s more flexible that way, but it’s simpler to use Epicor’s proper system.
> 
> Step 5. Either create a “Refresh” button or hook into the menu RefreshTool and make sure the above code runs when the user wants to make changes.
> 
> Updateable BAQs need a bit more code than this but can also be made to work very reliably.

I tried your method and I like it. Very powerful, I can do what I need without needing to worry about Epicor’s limitations. However, when I close the Dashboard, I get a “Save Confirmation” dialog popup. Not sure where this is coming from or how to suppress it. Did you have the same problem and how did you resolve it?

---

<div class="post-metadata">

**Author:** ![dhewi](https://www.epiusers.help/user_avatar/www.epiusers.help/dhewi/32/14166_2.png) [@dhewi](https://www.epiusers.help/u/dhewi)\
**Post date:** [August 16, 2018, 6:12am UTC](https://www.epiusers.help/t/passing-parameter-filter-in-dynamic-query/46665/23 "2018-08-16T06:12:47Z")

</div>

I’m glad to have someone else looking at this method, because it does open up a lot of possibilities.

The pop-up save on close is something we experience too, in most cases but oddly not all. I haven’t made a priority of getting to the bottom of it because it doesn’t seem to trouble any of our users, only me! They just click whatever they like and carry on without a further thought.

I assume the generic Epicor form has some kind of “dirty data” flag that activates for any EpiDataView and defaults to true, but I haven’t found it. If I do track down what’s going on then I’ll drop a note back, otherwise I’ll be grateful to know what you find.

---

<div class="post-metadata">

**Author:** ![dhewi](https://www.epiusers.help/user_avatar/www.epiusers.help/dhewi/32/14166_2.png) [@dhewi](https://www.epiusers.help/u/dhewi)\
**Post date:** [August 16, 2018, 7:33am UTC](https://www.epiusers.help/t/passing-parameter-filter-in-dynamic-query/46665/24 "2018-08-16T07:33:51Z")

</div>

I should add, by the way, that if you tick “Don’t show this again” when dismissing that Save Confirmation, you only need to deal with it once, so although it remains a niggle for those of us creating the dashboards that something isn’t quite right, it doesn’t affect anything much in practice.

---

<div class="post-metadata">

**Author:** ![mchernecki](https://www.epiusers.help/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@mchernecki](https://www.epiusers.help/u/mchernecki)\
**Post date:** [August 16, 2018, 1:40pm UTC](https://www.epiusers.help/t/passing-parameter-filter-in-dynamic-query/46665/25 "2018-08-16T13:40:30Z")

</div>

Again, Thanks for the suggestion. I will update if I find anything more on eliminating the popup.

---

<div class="post-metadata">

**Author:** ![A.Baeisa](https://www.epiusers.help/user_avatar/www.epiusers.help/a.baeisa/32/8988_2.png) [@A.Baeisa](https://www.epiusers.help/u/A.Baeisa)\
**Post date:** [October 19, 2018, 1:34pm UTC](https://www.epiusers.help/t/passing-parameter-filter-in-dynamic-query/46665/26 "2018-10-19T13:34:13Z")

</div>

great code, i want to use it in Normal UI Form (PartRev) , hooked to ‘click’ button, with two ‘And’ parameters PartNum and PartRev, but the problem is that all PartRev existed in the ds, any idea in how can i hook to the current PartRev parameter to be able to filter my dynamicquery to it as well as PartNum.

---

<div class="post-metadata">

**Author:** ![dhewi](https://www.epiusers.help/user_avatar/www.epiusers.help/dhewi/32/14166_2.png) [@dhewi](https://www.epiusers.help/u/dhewi)\
**Post date:** [October 19, 2018, 1:51pm UTC](https://www.epiusers.help/t/passing-parameter-filter-in-dynamic-query/46665/27 "2018-10-19T13:51:06Z")

</div>

I’m not familiar with that particular form, sorry.

But my general approach is to find which EpiDataView in the form contains the field data you want to work with, which is easily done in Customization mode by looking at the EpiBinding property of something that shows it. Then you can access that view with

```auto
EpiDataView edv = (EpiDataView)oTrans.EpiDataViews["viewname"];

```

It may have several rows, but the current one will be indexed with .Row, so you can get the field data for whatever is current with

```auto
edv.dataView[edv.Row]["columnname"]

```

It’s advisable to test for edv.Row \> -1 to avoid errors with empty views, and if you’re passing the result to a DynamicQuery parameter then adding .ToString() is also sensible.

Apologies if that’s a bit “ABC” in terms of instructions, but you never know who else might want to know the same thing later!

---

<div class="post-metadata">

**Author:** ![danbedwards](https://www.epiusers.help/letter_avatar_proxy/v4/letter/d/9f8e36/32.png) [@danbedwards](https://www.epiusers.help/u/danbedwards)\
**Post date:** [October 19, 2018, 5:05pm UTC](https://www.epiusers.help/t/passing-parameter-filter-in-dynamic-query/46665/28 "2018-10-19T17:05:34Z")

</div>

You could also use edv.CurrentDataRow[“columnname”]

> [@dhewi](#):
>
> so you can get the field data for whatever is current with

---

<div class="post-metadata">

**Author:** ![hkeric.wci](https://www.epiusers.help/user_avatar/www.epiusers.help/hkeric.wci/32/52019_2.png) [@hkeric.wci](https://www.epiusers.help/u/hkeric.wci)\
**Post date:** [October 19, 2018, 6:36pm UTC](https://www.epiusers.help/t/passing-parameter-filter-in-dynamic-query/46665/29 "2018-10-19T18:36:59Z")

</div>

Since we are on this topic, upvote: [Dashboard Pass Silent Parameters to BAQ - Feature Requests and Suggestions - Epicor User Help Forum](https://epiusers.help/t/dashboard-pass-silent-parameters-to-baq/46319)

[Previous page](https://www.epiusers.help/t/passing-parameter-filter-in-dynamic-query/46665.md?page=1)
