How To Call a BAQ from Customization Code?

I'm glad I could help!

Thanks for sharing your final code, I can see myself coping this example
for a upcoming task.



From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of zanniebelle
Sent: Friday, November 19, 2010 8:23 AM
To: vantage@yahoogroups.com
Subject: [Vantage] Re: How To Call a BAQ from Customization Code?





Hi Joe,
I used your advice and got it to work. I added the criteria rows to the
BAQ setting each field to ' '. Then I changed the value for each field
in my method before calling Execute(see code below).

Thanks for you help!

Ray

private static void GetSignHistory(string as_custNum, string
as_shipToNum, string as_partnum, string as_seq)
{
DynamicQuery dqa = new DynamicQuery(_session.ConnectionPool);
QueryDesignDataSet qdds = dqa.GetByID(SIGN_HISTORY_BAQ);

foreach (DataRow lo_row in qdds.QueryWhereItem.Rows)
{
switch (lo_row["FieldName"].ToString())
{
case "Key1":
lo_row["RValue"] = as_custNum;
break;
case "Key2":
lo_row["RValue"] = as_shipToNum;
break;
case "Key3":
lo_row["RValue"] = as_partnum;
break;
case "Key4":
lo_row["RValue"] = as_seq;
break;
}
}

DataSet ds = dqa.Execute(qdds);
epiUltraGridSignHistory.DataSource = ds;

}

--- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> , Joe
Rojas <jrojas@...> wrote:
>
> I think I remember having this issue but in my case I only had one
> criteria.
>
> The issue is that you can only have one new row at a time.
>
>
>
> In essence, you'd have to run Update(qdds) after each AddWhereItem.
>
> What I'm not sure about is if this will actually modify the BAQ on the
> server.
>
>
>
> Another approach would be to try and modify the RowMod field for the
new
> criteria after the AddWhereItem runs.
>
> Something like: qds.Tables["QueryWhereItem"].Rows[0]["RowMod"] = ""
>
> You'd have to change Rows[0] to the last number plus 1 (e.g. 0, 1, 2,
3)
>
>
>
> Lastly, you could define the criteria directly in the BAQ for Key 1 to
> Key 4 and set each on equal "", then after you retrieve the BAQ
dataset,
> modify each only using a similar syntax as above.
>
>
>
> Just spit balling here.
>
>
>
> From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
[mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ] On
Behalf
> Of zanniebelle
> Sent: Thursday, November 18, 2010 4:08 PM
> To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> Subject: [Vantage] Re: How To Call a BAQ from Customization Code?
>
>
>
>
>
> Hi Joe,
> I have tried to get this to work and I am able to call the BAQ, but it
> seems that I can only add one WhereItem. When I add more than one only
> the last one added affects the results. Do you see anything I'm doing
> wrong here?
>
> private static void GetSignHistory(string as_custNum, string
> as_shipToNum, string as_partnum, string as_seq)
> {
> DynamicQuery dqa = new DynamicQuery(_session.ConnectionPool);
> QueryDesignDataSet qdds = dqa.GetByID(SIGN_HISTORY_BAQ);
>
> string ls_queryId = SIGN_HISTORY_BAQ;
> string ls_table = "UD09";
> string ls_field = "Key1";
> string ls_condition = "=";
> string ls_empty = String.Empty;
> bool lb_isConst = true;
>
>
dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
> st,as_custNum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);
>
> ls_field = "Key2";
>
dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
> st,as_shipToNum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);
>
> ls_field = "Key3";
>
dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
> st,as_partnum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);
>
> ls_field = "Key4";
>
dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
> st,as_seq,ls_empty,ls_empty,ls_empty,ls_empty,"",false);
>
> DataSet ds = dqa.Execute(qdds);
> epiUltraGridSignHistory.DataSource = ds;
>
> }
>
> The results all have the same sequence (as_seq) number, but different
> part numbers and shipto numbers.
>
> If I comment out the last AddWhereItem the results only contains
records
> where there is a partnumber match (as_partNum)
>
> Any help you can provide is appreciated!
>
> Thanks,
>
> Ray
>
> --- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
<mailto:vantage%40yahoogroups.com> , Joe
> Rojas <jrojas@> wrote:
> >
> > Sorry, I was in a rush but I wanted to give you an answer.
> >
> > I decided to work with the BO instead of the adapter. If you're
> familiar
> > with working in the BAQ designer, some of these parameters should be
> > familiar.
> >
> > The example I gave is if you want to add criteria to your BAQ at
> > runtime. However, if you just want to call a BAQ without adding
> criteria
> > at runtime, then you can just call the ExexcuteByID method instead.
> >
> > I'll comment in the code below to try and explain.
> >
> >
> >
> >
> >
> >
> >
> > "<FormName>" is the name of the form you are calling this code from.
> It
> > can be found at the top of the tree view in the customization
screen.
> >
> > This creates a session object that is needed to create the
> DynamicQuery
> > BO
> >
> > Dim episession As Session = CType(<FormName>, Session)
> >
> >
> >
> > Create the DynamicQuery BO
> >
> > Dim dqa As DynamicQuery = New
DynamicQuery(episession.ConnectionPool)
> >
> >
> >
> > Pass the GetByID method the name of the BAQ that you want to call
> >
> > This will return a dataset that contains the details of the BAQ
> >
> > Dim ds As QueryDesignDataSet =
dqa.GetByID("MATS-ProjectInfluencers")
> >
> >
> >
> > ***********************
> >
> > Only use these variables if you need to add criteria at runtime
> >
> >
> >
> > The name of your BAQ
> >
> > Dim pcQueryID as String = "MATS-ProjectInfluencers"
> >
> >
> >
> > The name of the table in your BAQ that you want to add a criteria
> > against
> >
> > Dim pcTable as String = "UD04"
> >
> >
> >
> > The field in the table above that will be used in your criteria
> >
> > Dim pcField as String = "Key1"
> >
> >
> >
> > The comparison operator for your criteria
> >
> > Dim pcCondition as String = "="
> >
> >
> >
> > Set to true if comparing to a constant value, false if comparing to
> > another field
> >
> > Dim pbIsConst as Boolean = true
> >
> >
> >
> > If above is true, the constant value
> >
> > Dim pcValue as String = "2010-0"
> >
> >
> >
> > If pbIsConst is false then this is the comparison table
> >
> > Dim pcToTable as String = String.Empty
> >
> >
> >
> > If pbIsConst is false then this is the comparison field
> >
> > Dim pcToField as String = String.Empty
> >
> >
> >
> > Do you want to set a left parentheses
> >
> > Dim pcLeftParentheses as String = String.Empty
> >
> >
> >
> > Do you want to set a right parentheses
> >
> > Dim pcRightParentheses as String = String.Empty
> >
> >
> >
> > If assigned more than one criteria, set the And or Or between the
> > criteria
> >
> > Dim pcAndOr as String = String.Empty
> >
> >
> >
> > Is this a negation criteria, same as checking the Not checkox
> >
> > Dim pbNeg as Boolean = false
> >
> >
> >
> > Calls AddWhereItem to add the criteria created above to BAQ dataset
> >
> > dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,
> >
> > pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,
> >
> > pcRightParentheses, pcAndOr, pbNeg)
> >
> > *******************************
> >
> >
> >
> > Execute the BAQ and store the results in a dataset
> >
> > Dim DQResults As DataSet = dqa.Execute(ds)
> >
> >
> >
> > Assign the dataset to an EpiUltraGrid
> >
> > ugInfluencers.DataSource = DQResults
> >
> >
> >
> > From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
<mailto:vantage%40yahoogroups.com>
> [mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
<mailto:vantage%40yahoogroups.com> ] On
> Behalf
> > Of zanniebelle
> > Sent: Thursday, November 18, 2010 1:15 PM
> > To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
<mailto:vantage%40yahoogroups.com>
> > Subject: [Vantage] Re: How To Call a BAQ from Customization Code?
> >
> >
> >
> >
> >
> > Thanks Joe for the reply.
> >
> > Can you provide a little more detail on the parameters and their
> > purpose?
> >
> > For example is "MATS-ProjectInfluencers" the BAQ your calling?
> >
> > Ray
> >
> > Any additional help is appreciated.
> >
> > --- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
<mailto:vantage%40yahoogroups.com>
> <mailto:vantage%40yahoogroups.com> , Joe
> > Rojas <jrojas@> wrote:
> > >
> > > Here is an example that I posted a few months back
> > >
> > >
> > >
> > > Dim episession As Session = CType(<FormName>, Session)
> > >
> > >
> > >
> > > Dim dqa As DynamicQuery = New
> DynamicQuery(episession.ConnectionPool)
> > >
> > >
> > >
> > > Dim ds As QueryDesignDataSet =
> dqa.GetByID("MATS-ProjectInfluencers")
> > >
> > >
> > >
> > > Dim pcQueryID as String = "MATS-ProjectInfluencers"
> > >
> > >
> > >
> > > Dim pcTable as String = "UD04"
> > >
> > >
> > >
> > > Dim pcField as String = "Key1"
> > >
> > >
> > >
> > > Dim pcCondition as String = "="
> > >
> > >
> > >
> > > Dim pbIsConst as Boolean = true
> > >
> > >
> > >
> > > Dim pcValue as String = "2010-0"
> > >
> > >
> > >
> > > Dim pcToTable as String = String.Empty
> > >
> > >
> > >
> > > Dim pcToField as String = String.Empty
> > >
> > >
> > >
> > > Dim pcLeftParentheses as String = String.Empty
> > >
> > >
> > >
> > > Dim pcRightParentheses as String = String.Empty
> > >
> > >
> > >
> > > Dim pcAndOr as String = String.Empty
> > >
> > >
> > >
> > > Dim pbNeg as Boolean = false
> > >
> > >
> > >
> > > dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,
> > >
> > > pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,
> > >
> > > pcRightParentheses, pcAndOr, pbNeg)
> > >
> > >
> > >
> > > Dim DQResults As DataSet = dqa.Execute(ds)
> > >
> > >
> > >
> > > ugInfluencers.DataSource = DQResults
> > >
> > >
> > >
> > > From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
<mailto:vantage%40yahoogroups.com>
> <mailto:vantage%40yahoogroups.com>
> > [mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
<mailto:vantage%40yahoogroups.com>
> <mailto:vantage%40yahoogroups.com> ] On
> > Behalf
> > > Of zanniebelle
> > > Sent: Thursday, November 18, 2010 12:57 PM
> > > To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
<mailto:vantage%40yahoogroups.com>
> <mailto:vantage%40yahoogroups.com>
> > > Subject: [Vantage] How To Call a BAQ from Customization Code?
> > >
> > >
> > >
> > >
> > >
> > > Hi All,
> > >
> > > Does anyone have an example of calling a BAQ from customization
code
> > > that will fill a DataSet?
> > >
> > > Thanks,
> > >
> > > Ray
> > >
> > >
> > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
> [Non-text portions of this message have been removed]
>












Joe Rojas | Director of Information Technology | Mats Inc
dir: 781-573-0291 | cell: 781-408-9278 | fax: 781-232-5191
jrojas@... | www.matsinc.com Ask us about our clean, green and beautiful matting and flooring


This message is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company.


[Non-text portions of this message have been removed]
Hi All,

Does anyone have an example of calling a BAQ from customization code that will fill a DataSet?

Thanks,

Ray
Here is an example that I posted a few months back



Dim episession As Session = CType(<FormName>, Session)



Dim dqa As DynamicQuery = New DynamicQuery(episession.ConnectionPool)



Dim ds As QueryDesignDataSet = dqa.GetByID("MATS-ProjectInfluencers")



Dim pcQueryID as String = "MATS-ProjectInfluencers"



Dim pcTable as String = "UD04"



Dim pcField as String = "Key1"



Dim pcCondition as String = "="



Dim pbIsConst as Boolean = true



Dim pcValue as String = "2010-0"



Dim pcToTable as String = String.Empty



Dim pcToField as String = String.Empty



Dim pcLeftParentheses as String = String.Empty



Dim pcRightParentheses as String = String.Empty



Dim pcAndOr as String = String.Empty



Dim pbNeg as Boolean = false



dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,

pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,

pcRightParentheses, pcAndOr, pbNeg)



Dim DQResults As DataSet = dqa.Execute(ds)



ugInfluencers.DataSource = DQResults



From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of zanniebelle
Sent: Thursday, November 18, 2010 12:57 PM
To: vantage@yahoogroups.com
Subject: [Vantage] How To Call a BAQ from Customization Code?





Hi All,

Does anyone have an example of calling a BAQ from customization code
that will fill a DataSet?

Thanks,

Ray




[Non-text portions of this message have been removed]
Thanks Joe for the reply.

Can you provide a little more detail on the parameters and their purpose?

For example is "MATS-ProjectInfluencers" the BAQ your calling?

Ray

Any additional help is appreciated.

--- In vantage@yahoogroups.com, Joe Rojas <jrojas@...> wrote:
>
> Here is an example that I posted a few months back
>
>
>
> Dim episession As Session = CType(<FormName>, Session)
>
>
>
> Dim dqa As DynamicQuery = New DynamicQuery(episession.ConnectionPool)
>
>
>
> Dim ds As QueryDesignDataSet = dqa.GetByID("MATS-ProjectInfluencers")
>
>
>
> Dim pcQueryID as String = "MATS-ProjectInfluencers"
>
>
>
> Dim pcTable as String = "UD04"
>
>
>
> Dim pcField as String = "Key1"
>
>
>
> Dim pcCondition as String = "="
>
>
>
> Dim pbIsConst as Boolean = true
>
>
>
> Dim pcValue as String = "2010-0"
>
>
>
> Dim pcToTable as String = String.Empty
>
>
>
> Dim pcToField as String = String.Empty
>
>
>
> Dim pcLeftParentheses as String = String.Empty
>
>
>
> Dim pcRightParentheses as String = String.Empty
>
>
>
> Dim pcAndOr as String = String.Empty
>
>
>
> Dim pbNeg as Boolean = false
>
>
>
> dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,
>
> pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,
>
> pcRightParentheses, pcAndOr, pbNeg)
>
>
>
> Dim DQResults As DataSet = dqa.Execute(ds)
>
>
>
> ugInfluencers.DataSource = DQResults
>
>
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> Of zanniebelle
> Sent: Thursday, November 18, 2010 12:57 PM
> To: vantage@yahoogroups.com
> Subject: [Vantage] How To Call a BAQ from Customization Code?
>
>
>
>
>
> Hi All,
>
> Does anyone have an example of calling a BAQ from customization code
> that will fill a DataSet?
>
> Thanks,
>
> Ray
>
>
>
>
> [Non-text portions of this message have been removed]
>
Sorry, I was in a rush but I wanted to give you an answer.

I decided to work with the BO instead of the adapter. If you're familiar
with working in the BAQ designer, some of these parameters should be
familiar.

The example I gave is if you want to add criteria to your BAQ at
runtime. However, if you just want to call a BAQ without adding criteria
at runtime, then you can just call the ExexcuteByID method instead.

I'll comment in the code below to try and explain.







"<FormName>" is the name of the form you are calling this code from. It
can be found at the top of the tree view in the customization screen.

This creates a session object that is needed to create the DynamicQuery
BO

Dim episession As Session = CType(<FormName>, Session)



Create the DynamicQuery BO

Dim dqa As DynamicQuery = New DynamicQuery(episession.ConnectionPool)



Pass the GetByID method the name of the BAQ that you want to call

This will return a dataset that contains the details of the BAQ

Dim ds As QueryDesignDataSet = dqa.GetByID("MATS-ProjectInfluencers")



***********************

Only use these variables if you need to add criteria at runtime



The name of your BAQ

Dim pcQueryID as String = "MATS-ProjectInfluencers"



The name of the table in your BAQ that you want to add a criteria
against

Dim pcTable as String = "UD04"



The field in the table above that will be used in your criteria

Dim pcField as String = "Key1"



The comparison operator for your criteria

Dim pcCondition as String = "="



Set to true if comparing to a constant value, false if comparing to
another field

Dim pbIsConst as Boolean = true



If above is true, the constant value

Dim pcValue as String = "2010-0"



If pbIsConst is false then this is the comparison table

Dim pcToTable as String = String.Empty



If pbIsConst is false then this is the comparison field

Dim pcToField as String = String.Empty



Do you want to set a left parentheses

Dim pcLeftParentheses as String = String.Empty



Do you want to set a right parentheses

Dim pcRightParentheses as String = String.Empty



If assigned more than one criteria, set the And or Or between the
criteria

Dim pcAndOr as String = String.Empty



Is this a negation criteria, same as checking the Not checkox

Dim pbNeg as Boolean = false



Calls AddWhereItem to add the criteria created above to BAQ dataset

dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,

pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,

pcRightParentheses, pcAndOr, pbNeg)

*******************************



Execute the BAQ and store the results in a dataset

Dim DQResults As DataSet = dqa.Execute(ds)



Assign the dataset to an EpiUltraGrid

ugInfluencers.DataSource = DQResults



From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of zanniebelle
Sent: Thursday, November 18, 2010 1:15 PM
To: vantage@yahoogroups.com
Subject: [Vantage] Re: How To Call a BAQ from Customization Code?





Thanks Joe for the reply.

Can you provide a little more detail on the parameters and their
purpose?

For example is "MATS-ProjectInfluencers" the BAQ your calling?

Ray

Any additional help is appreciated.

--- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> , Joe
Rojas <jrojas@...> wrote:
>
> Here is an example that I posted a few months back
>
>
>
> Dim episession As Session = CType(<FormName>, Session)
>
>
>
> Dim dqa As DynamicQuery = New DynamicQuery(episession.ConnectionPool)
>
>
>
> Dim ds As QueryDesignDataSet = dqa.GetByID("MATS-ProjectInfluencers")
>
>
>
> Dim pcQueryID as String = "MATS-ProjectInfluencers"
>
>
>
> Dim pcTable as String = "UD04"
>
>
>
> Dim pcField as String = "Key1"
>
>
>
> Dim pcCondition as String = "="
>
>
>
> Dim pbIsConst as Boolean = true
>
>
>
> Dim pcValue as String = "2010-0"
>
>
>
> Dim pcToTable as String = String.Empty
>
>
>
> Dim pcToField as String = String.Empty
>
>
>
> Dim pcLeftParentheses as String = String.Empty
>
>
>
> Dim pcRightParentheses as String = String.Empty
>
>
>
> Dim pcAndOr as String = String.Empty
>
>
>
> Dim pbNeg as Boolean = false
>
>
>
> dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,
>
> pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,
>
> pcRightParentheses, pcAndOr, pbNeg)
>
>
>
> Dim DQResults As DataSet = dqa.Execute(ds)
>
>
>
> ugInfluencers.DataSource = DQResults
>
>
>
> From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
[mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ] On
Behalf
> Of zanniebelle
> Sent: Thursday, November 18, 2010 12:57 PM
> To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> Subject: [Vantage] How To Call a BAQ from Customization Code?
>
>
>
>
>
> Hi All,
>
> Does anyone have an example of calling a BAQ from customization code
> that will fill a DataSet?
>
> Thanks,
>
> Ray
>
>
>
>
> [Non-text portions of this message have been removed]
>




[Non-text portions of this message have been removed]
Perfect! Thanks for your help!!

--- In vantage@yahoogroups.com, Joe Rojas <jrojas@...> wrote:
>
> Sorry, I was in a rush but I wanted to give you an answer.
>
> I decided to work with the BO instead of the adapter. If you're familiar
> with working in the BAQ designer, some of these parameters should be
> familiar.
>
> The example I gave is if you want to add criteria to your BAQ at
> runtime. However, if you just want to call a BAQ without adding criteria
> at runtime, then you can just call the ExexcuteByID method instead.
>
> I'll comment in the code below to try and explain.
>
>
>
>
>
>
>
> "<FormName>" is the name of the form you are calling this code from. It
> can be found at the top of the tree view in the customization screen.
>
> This creates a session object that is needed to create the DynamicQuery
> BO
>
> Dim episession As Session = CType(<FormName>, Session)
>
>
>
> Create the DynamicQuery BO
>
> Dim dqa As DynamicQuery = New DynamicQuery(episession.ConnectionPool)
>
>
>
> Pass the GetByID method the name of the BAQ that you want to call
>
> This will return a dataset that contains the details of the BAQ
>
> Dim ds As QueryDesignDataSet = dqa.GetByID("MATS-ProjectInfluencers")
>
>
>
> ***********************
>
> Only use these variables if you need to add criteria at runtime
>
>
>
> The name of your BAQ
>
> Dim pcQueryID as String = "MATS-ProjectInfluencers"
>
>
>
> The name of the table in your BAQ that you want to add a criteria
> against
>
> Dim pcTable as String = "UD04"
>
>
>
> The field in the table above that will be used in your criteria
>
> Dim pcField as String = "Key1"
>
>
>
> The comparison operator for your criteria
>
> Dim pcCondition as String = "="
>
>
>
> Set to true if comparing to a constant value, false if comparing to
> another field
>
> Dim pbIsConst as Boolean = true
>
>
>
> If above is true, the constant value
>
> Dim pcValue as String = "2010-0"
>
>
>
> If pbIsConst is false then this is the comparison table
>
> Dim pcToTable as String = String.Empty
>
>
>
> If pbIsConst is false then this is the comparison field
>
> Dim pcToField as String = String.Empty
>
>
>
> Do you want to set a left parentheses
>
> Dim pcLeftParentheses as String = String.Empty
>
>
>
> Do you want to set a right parentheses
>
> Dim pcRightParentheses as String = String.Empty
>
>
>
> If assigned more than one criteria, set the And or Or between the
> criteria
>
> Dim pcAndOr as String = String.Empty
>
>
>
> Is this a negation criteria, same as checking the Not checkox
>
> Dim pbNeg as Boolean = false
>
>
>
> Calls AddWhereItem to add the criteria created above to BAQ dataset
>
> dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,
>
> pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,
>
> pcRightParentheses, pcAndOr, pbNeg)
>
> *******************************
>
>
>
> Execute the BAQ and store the results in a dataset
>
> Dim DQResults As DataSet = dqa.Execute(ds)
>
>
>
> Assign the dataset to an EpiUltraGrid
>
> ugInfluencers.DataSource = DQResults
>
>
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> Of zanniebelle
> Sent: Thursday, November 18, 2010 1:15 PM
> To: vantage@yahoogroups.com
> Subject: [Vantage] Re: How To Call a BAQ from Customization Code?
>
>
>
>
>
> Thanks Joe for the reply.
>
> Can you provide a little more detail on the parameters and their
> purpose?
>
> For example is "MATS-ProjectInfluencers" the BAQ your calling?
>
> Ray
>
> Any additional help is appreciated.
>
> --- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> , Joe
> Rojas <jrojas@> wrote:
> >
> > Here is an example that I posted a few months back
> >
> >
> >
> > Dim episession As Session = CType(<FormName>, Session)
> >
> >
> >
> > Dim dqa As DynamicQuery = New DynamicQuery(episession.ConnectionPool)
> >
> >
> >
> > Dim ds As QueryDesignDataSet = dqa.GetByID("MATS-ProjectInfluencers")
> >
> >
> >
> > Dim pcQueryID as String = "MATS-ProjectInfluencers"
> >
> >
> >
> > Dim pcTable as String = "UD04"
> >
> >
> >
> > Dim pcField as String = "Key1"
> >
> >
> >
> > Dim pcCondition as String = "="
> >
> >
> >
> > Dim pbIsConst as Boolean = true
> >
> >
> >
> > Dim pcValue as String = "2010-0"
> >
> >
> >
> > Dim pcToTable as String = String.Empty
> >
> >
> >
> > Dim pcToField as String = String.Empty
> >
> >
> >
> > Dim pcLeftParentheses as String = String.Empty
> >
> >
> >
> > Dim pcRightParentheses as String = String.Empty
> >
> >
> >
> > Dim pcAndOr as String = String.Empty
> >
> >
> >
> > Dim pbNeg as Boolean = false
> >
> >
> >
> > dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,
> >
> > pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,
> >
> > pcRightParentheses, pcAndOr, pbNeg)
> >
> >
> >
> > Dim DQResults As DataSet = dqa.Execute(ds)
> >
> >
> >
> > ugInfluencers.DataSource = DQResults
> >
> >
> >
> > From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> [mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ] On
> Behalf
> > Of zanniebelle
> > Sent: Thursday, November 18, 2010 12:57 PM
> > To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> > Subject: [Vantage] How To Call a BAQ from Customization Code?
> >
> >
> >
> >
> >
> > Hi All,
> >
> > Does anyone have an example of calling a BAQ from customization code
> > that will fill a DataSet?
> >
> > Thanks,
> >
> > Ray
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
> [Non-text portions of this message have been removed]
>
Hi Joe,
I have tried to get this to work and I am able to call the BAQ, but it seems that I can only add one WhereItem. When I add more than one only the last one added affects the results. Do you see anything I'm doing wrong here?

private static void GetSignHistory(string as_custNum, string as_shipToNum, string as_partnum, string as_seq)
{
DynamicQuery dqa = new DynamicQuery(_session.ConnectionPool);
QueryDesignDataSet qdds = dqa.GetByID(SIGN_HISTORY_BAQ);

string ls_queryId = SIGN_HISTORY_BAQ;
string ls_table = "UD09";
string ls_field = "Key1";
string ls_condition = "=";
string ls_empty = String.Empty;
bool lb_isConst = true;

dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isConst,as_custNum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);

ls_field = "Key2";
dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isConst,as_shipToNum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);

ls_field = "Key3";
dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isConst,as_partnum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);

ls_field = "Key4";
dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isConst,as_seq,ls_empty,ls_empty,ls_empty,ls_empty,"",false);

DataSet ds = dqa.Execute(qdds);
epiUltraGridSignHistory.DataSource = ds;

}

The results all have the same sequence (as_seq) number, but different part numbers and shipto numbers.

If I comment out the last AddWhereItem the results only contains records where there is a partnumber match (as_partNum)

Any help you can provide is appreciated!

Thanks,

Ray

--- In vantage@yahoogroups.com, Joe Rojas <jrojas@...> wrote:
>
> Sorry, I was in a rush but I wanted to give you an answer.
>
> I decided to work with the BO instead of the adapter. If you're familiar
> with working in the BAQ designer, some of these parameters should be
> familiar.
>
> The example I gave is if you want to add criteria to your BAQ at
> runtime. However, if you just want to call a BAQ without adding criteria
> at runtime, then you can just call the ExexcuteByID method instead.
>
> I'll comment in the code below to try and explain.
>
>
>
>
>
>
>
> "<FormName>" is the name of the form you are calling this code from. It
> can be found at the top of the tree view in the customization screen.
>
> This creates a session object that is needed to create the DynamicQuery
> BO
>
> Dim episession As Session = CType(<FormName>, Session)
>
>
>
> Create the DynamicQuery BO
>
> Dim dqa As DynamicQuery = New DynamicQuery(episession.ConnectionPool)
>
>
>
> Pass the GetByID method the name of the BAQ that you want to call
>
> This will return a dataset that contains the details of the BAQ
>
> Dim ds As QueryDesignDataSet = dqa.GetByID("MATS-ProjectInfluencers")
>
>
>
> ***********************
>
> Only use these variables if you need to add criteria at runtime
>
>
>
> The name of your BAQ
>
> Dim pcQueryID as String = "MATS-ProjectInfluencers"
>
>
>
> The name of the table in your BAQ that you want to add a criteria
> against
>
> Dim pcTable as String = "UD04"
>
>
>
> The field in the table above that will be used in your criteria
>
> Dim pcField as String = "Key1"
>
>
>
> The comparison operator for your criteria
>
> Dim pcCondition as String = "="
>
>
>
> Set to true if comparing to a constant value, false if comparing to
> another field
>
> Dim pbIsConst as Boolean = true
>
>
>
> If above is true, the constant value
>
> Dim pcValue as String = "2010-0"
>
>
>
> If pbIsConst is false then this is the comparison table
>
> Dim pcToTable as String = String.Empty
>
>
>
> If pbIsConst is false then this is the comparison field
>
> Dim pcToField as String = String.Empty
>
>
>
> Do you want to set a left parentheses
>
> Dim pcLeftParentheses as String = String.Empty
>
>
>
> Do you want to set a right parentheses
>
> Dim pcRightParentheses as String = String.Empty
>
>
>
> If assigned more than one criteria, set the And or Or between the
> criteria
>
> Dim pcAndOr as String = String.Empty
>
>
>
> Is this a negation criteria, same as checking the Not checkox
>
> Dim pbNeg as Boolean = false
>
>
>
> Calls AddWhereItem to add the criteria created above to BAQ dataset
>
> dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,
>
> pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,
>
> pcRightParentheses, pcAndOr, pbNeg)
>
> *******************************
>
>
>
> Execute the BAQ and store the results in a dataset
>
> Dim DQResults As DataSet = dqa.Execute(ds)
>
>
>
> Assign the dataset to an EpiUltraGrid
>
> ugInfluencers.DataSource = DQResults
>
>
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> Of zanniebelle
> Sent: Thursday, November 18, 2010 1:15 PM
> To: vantage@yahoogroups.com
> Subject: [Vantage] Re: How To Call a BAQ from Customization Code?
>
>
>
>
>
> Thanks Joe for the reply.
>
> Can you provide a little more detail on the parameters and their
> purpose?
>
> For example is "MATS-ProjectInfluencers" the BAQ your calling?
>
> Ray
>
> Any additional help is appreciated.
>
> --- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> , Joe
> Rojas <jrojas@> wrote:
> >
> > Here is an example that I posted a few months back
> >
> >
> >
> > Dim episession As Session = CType(<FormName>, Session)
> >
> >
> >
> > Dim dqa As DynamicQuery = New DynamicQuery(episession.ConnectionPool)
> >
> >
> >
> > Dim ds As QueryDesignDataSet = dqa.GetByID("MATS-ProjectInfluencers")
> >
> >
> >
> > Dim pcQueryID as String = "MATS-ProjectInfluencers"
> >
> >
> >
> > Dim pcTable as String = "UD04"
> >
> >
> >
> > Dim pcField as String = "Key1"
> >
> >
> >
> > Dim pcCondition as String = "="
> >
> >
> >
> > Dim pbIsConst as Boolean = true
> >
> >
> >
> > Dim pcValue as String = "2010-0"
> >
> >
> >
> > Dim pcToTable as String = String.Empty
> >
> >
> >
> > Dim pcToField as String = String.Empty
> >
> >
> >
> > Dim pcLeftParentheses as String = String.Empty
> >
> >
> >
> > Dim pcRightParentheses as String = String.Empty
> >
> >
> >
> > Dim pcAndOr as String = String.Empty
> >
> >
> >
> > Dim pbNeg as Boolean = false
> >
> >
> >
> > dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,
> >
> > pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,
> >
> > pcRightParentheses, pcAndOr, pbNeg)
> >
> >
> >
> > Dim DQResults As DataSet = dqa.Execute(ds)
> >
> >
> >
> > ugInfluencers.DataSource = DQResults
> >
> >
> >
> > From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> [mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ] On
> Behalf
> > Of zanniebelle
> > Sent: Thursday, November 18, 2010 12:57 PM
> > To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> > Subject: [Vantage] How To Call a BAQ from Customization Code?
> >
> >
> >
> >
> >
> > Hi All,
> >
> > Does anyone have an example of calling a BAQ from customization code
> > that will fill a DataSet?
> >
> > Thanks,
> >
> > Ray
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
> [Non-text portions of this message have been removed]
>
I think I remember having this issue but in my case I only had one
criteria.

The issue is that you can only have one new row at a time.



In essence, you'd have to run Update(qdds) after each AddWhereItem.

What I'm not sure about is if this will actually modify the BAQ on the
server.



Another approach would be to try and modify the RowMod field for the new
criteria after the AddWhereItem runs.

Something like: qds.Tables["QueryWhereItem"].Rows[0]["RowMod"] = ""

You'd have to change Rows[0] to the last number plus 1 (e.g. 0, 1, 2, 3)



Lastly, you could define the criteria directly in the BAQ for Key 1 to
Key 4 and set each on equal "", then after you retrieve the BAQ dataset,
modify each only using a similar syntax as above.



Just spit balling here.



From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of zanniebelle
Sent: Thursday, November 18, 2010 4:08 PM
To: vantage@yahoogroups.com
Subject: [Vantage] Re: How To Call a BAQ from Customization Code?





Hi Joe,
I have tried to get this to work and I am able to call the BAQ, but it
seems that I can only add one WhereItem. When I add more than one only
the last one added affects the results. Do you see anything I'm doing
wrong here?

private static void GetSignHistory(string as_custNum, string
as_shipToNum, string as_partnum, string as_seq)
{
DynamicQuery dqa = new DynamicQuery(_session.ConnectionPool);
QueryDesignDataSet qdds = dqa.GetByID(SIGN_HISTORY_BAQ);

string ls_queryId = SIGN_HISTORY_BAQ;
string ls_table = "UD09";
string ls_field = "Key1";
string ls_condition = "=";
string ls_empty = String.Empty;
bool lb_isConst = true;

dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
st,as_custNum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);

ls_field = "Key2";
dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
st,as_shipToNum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);

ls_field = "Key3";
dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
st,as_partnum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);

ls_field = "Key4";
dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
st,as_seq,ls_empty,ls_empty,ls_empty,ls_empty,"",false);

DataSet ds = dqa.Execute(qdds);
epiUltraGridSignHistory.DataSource = ds;

}

The results all have the same sequence (as_seq) number, but different
part numbers and shipto numbers.

If I comment out the last AddWhereItem the results only contains records
where there is a partnumber match (as_partNum)

Any help you can provide is appreciated!

Thanks,

Ray

--- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> , Joe
Rojas <jrojas@...> wrote:
>
> Sorry, I was in a rush but I wanted to give you an answer.
>
> I decided to work with the BO instead of the adapter. If you're
familiar
> with working in the BAQ designer, some of these parameters should be
> familiar.
>
> The example I gave is if you want to add criteria to your BAQ at
> runtime. However, if you just want to call a BAQ without adding
criteria
> at runtime, then you can just call the ExexcuteByID method instead.
>
> I'll comment in the code below to try and explain.
>
>
>
>
>
>
>
> "<FormName>" is the name of the form you are calling this code from.
It
> can be found at the top of the tree view in the customization screen.
>
> This creates a session object that is needed to create the
DynamicQuery
> BO
>
> Dim episession As Session = CType(<FormName>, Session)
>
>
>
> Create the DynamicQuery BO
>
> Dim dqa As DynamicQuery = New DynamicQuery(episession.ConnectionPool)
>
>
>
> Pass the GetByID method the name of the BAQ that you want to call
>
> This will return a dataset that contains the details of the BAQ
>
> Dim ds As QueryDesignDataSet = dqa.GetByID("MATS-ProjectInfluencers")
>
>
>
> ***********************
>
> Only use these variables if you need to add criteria at runtime
>
>
>
> The name of your BAQ
>
> Dim pcQueryID as String = "MATS-ProjectInfluencers"
>
>
>
> The name of the table in your BAQ that you want to add a criteria
> against
>
> Dim pcTable as String = "UD04"
>
>
>
> The field in the table above that will be used in your criteria
>
> Dim pcField as String = "Key1"
>
>
>
> The comparison operator for your criteria
>
> Dim pcCondition as String = "="
>
>
>
> Set to true if comparing to a constant value, false if comparing to
> another field
>
> Dim pbIsConst as Boolean = true
>
>
>
> If above is true, the constant value
>
> Dim pcValue as String = "2010-0"
>
>
>
> If pbIsConst is false then this is the comparison table
>
> Dim pcToTable as String = String.Empty
>
>
>
> If pbIsConst is false then this is the comparison field
>
> Dim pcToField as String = String.Empty
>
>
>
> Do you want to set a left parentheses
>
> Dim pcLeftParentheses as String = String.Empty
>
>
>
> Do you want to set a right parentheses
>
> Dim pcRightParentheses as String = String.Empty
>
>
>
> If assigned more than one criteria, set the And or Or between the
> criteria
>
> Dim pcAndOr as String = String.Empty
>
>
>
> Is this a negation criteria, same as checking the Not checkox
>
> Dim pbNeg as Boolean = false
>
>
>
> Calls AddWhereItem to add the criteria created above to BAQ dataset
>
> dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,
>
> pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,
>
> pcRightParentheses, pcAndOr, pbNeg)
>
> *******************************
>
>
>
> Execute the BAQ and store the results in a dataset
>
> Dim DQResults As DataSet = dqa.Execute(ds)
>
>
>
> Assign the dataset to an EpiUltraGrid
>
> ugInfluencers.DataSource = DQResults
>
>
>
> From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
[mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ] On
Behalf
> Of zanniebelle
> Sent: Thursday, November 18, 2010 1:15 PM
> To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> Subject: [Vantage] Re: How To Call a BAQ from Customization Code?
>
>
>
>
>
> Thanks Joe for the reply.
>
> Can you provide a little more detail on the parameters and their
> purpose?
>
> For example is "MATS-ProjectInfluencers" the BAQ your calling?
>
> Ray
>
> Any additional help is appreciated.
>
> --- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
<mailto:vantage%40yahoogroups.com> , Joe
> Rojas <jrojas@> wrote:
> >
> > Here is an example that I posted a few months back
> >
> >
> >
> > Dim episession As Session = CType(<FormName>, Session)
> >
> >
> >
> > Dim dqa As DynamicQuery = New
DynamicQuery(episession.ConnectionPool)
> >
> >
> >
> > Dim ds As QueryDesignDataSet =
dqa.GetByID("MATS-ProjectInfluencers")
> >
> >
> >
> > Dim pcQueryID as String = "MATS-ProjectInfluencers"
> >
> >
> >
> > Dim pcTable as String = "UD04"
> >
> >
> >
> > Dim pcField as String = "Key1"
> >
> >
> >
> > Dim pcCondition as String = "="
> >
> >
> >
> > Dim pbIsConst as Boolean = true
> >
> >
> >
> > Dim pcValue as String = "2010-0"
> >
> >
> >
> > Dim pcToTable as String = String.Empty
> >
> >
> >
> > Dim pcToField as String = String.Empty
> >
> >
> >
> > Dim pcLeftParentheses as String = String.Empty
> >
> >
> >
> > Dim pcRightParentheses as String = String.Empty
> >
> >
> >
> > Dim pcAndOr as String = String.Empty
> >
> >
> >
> > Dim pbNeg as Boolean = false
> >
> >
> >
> > dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,
> >
> > pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,
> >
> > pcRightParentheses, pcAndOr, pbNeg)
> >
> >
> >
> > Dim DQResults As DataSet = dqa.Execute(ds)
> >
> >
> >
> > ugInfluencers.DataSource = DQResults
> >
> >
> >
> > From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
<mailto:vantage%40yahoogroups.com>
> [mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
<mailto:vantage%40yahoogroups.com> ] On
> Behalf
> > Of zanniebelle
> > Sent: Thursday, November 18, 2010 12:57 PM
> > To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
<mailto:vantage%40yahoogroups.com>
> > Subject: [Vantage] How To Call a BAQ from Customization Code?
> >
> >
> >
> >
> >
> > Hi All,
> >
> > Does anyone have an example of calling a BAQ from customization code
> > that will fill a DataSet?
> >
> > Thanks,
> >
> > Ray
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
> [Non-text portions of this message have been removed]
>




[Non-text portions of this message have been removed]
Thanks again, I'll give your ideas a try.

As a last resort I'll store Key1+Key2+Key3+Key4 in a shortchar field whenever I add new records and then add a where item where shortcharXX = passed in values.

I tried using a calculated field in the BAQ, but couldn't find a way to get to it...the AddWhereItem expects a table name and a calculated field doen't have a table.

Anyway, thanks again!

Ray



--- In vantage@yahoogroups.com, Joe Rojas <jrojas@...> wrote:
>
> I think I remember having this issue but in my case I only had one
> criteria.
>
> The issue is that you can only have one new row at a time.
>
>
>
> In essence, you'd have to run Update(qdds) after each AddWhereItem.
>
> What I'm not sure about is if this will actually modify the BAQ on the
> server.
>
>
>
> Another approach would be to try and modify the RowMod field for the new
> criteria after the AddWhereItem runs.
>
> Something like: qds.Tables["QueryWhereItem"].Rows[0]["RowMod"] = ""
>
> You'd have to change Rows[0] to the last number plus 1 (e.g. 0, 1, 2, 3)
>
>
>
> Lastly, you could define the criteria directly in the BAQ for Key 1 to
> Key 4 and set each on equal "", then after you retrieve the BAQ dataset,
> modify each only using a similar syntax as above.
>
>
>
> Just spit balling here.
>
>
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> Of zanniebelle
> Sent: Thursday, November 18, 2010 4:08 PM
> To: vantage@yahoogroups.com
> Subject: [Vantage] Re: How To Call a BAQ from Customization Code?
>
>
>
>
>
> Hi Joe,
> I have tried to get this to work and I am able to call the BAQ, but it
> seems that I can only add one WhereItem. When I add more than one only
> the last one added affects the results. Do you see anything I'm doing
> wrong here?
>
> private static void GetSignHistory(string as_custNum, string
> as_shipToNum, string as_partnum, string as_seq)
> {
> DynamicQuery dqa = new DynamicQuery(_session.ConnectionPool);
> QueryDesignDataSet qdds = dqa.GetByID(SIGN_HISTORY_BAQ);
>
> string ls_queryId = SIGN_HISTORY_BAQ;
> string ls_table = "UD09";
> string ls_field = "Key1";
> string ls_condition = "=";
> string ls_empty = String.Empty;
> bool lb_isConst = true;
>
> dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
> st,as_custNum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);
>
> ls_field = "Key2";
> dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
> st,as_shipToNum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);
>
> ls_field = "Key3";
> dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
> st,as_partnum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);
>
> ls_field = "Key4";
> dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
> st,as_seq,ls_empty,ls_empty,ls_empty,ls_empty,"",false);
>
> DataSet ds = dqa.Execute(qdds);
> epiUltraGridSignHistory.DataSource = ds;
>
> }
>
> The results all have the same sequence (as_seq) number, but different
> part numbers and shipto numbers.
>
> If I comment out the last AddWhereItem the results only contains records
> where there is a partnumber match (as_partNum)
>
> Any help you can provide is appreciated!
>
> Thanks,
>
> Ray
>
> --- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> , Joe
> Rojas <jrojas@> wrote:
> >
> > Sorry, I was in a rush but I wanted to give you an answer.
> >
> > I decided to work with the BO instead of the adapter. If you're
> familiar
> > with working in the BAQ designer, some of these parameters should be
> > familiar.
> >
> > The example I gave is if you want to add criteria to your BAQ at
> > runtime. However, if you just want to call a BAQ without adding
> criteria
> > at runtime, then you can just call the ExexcuteByID method instead.
> >
> > I'll comment in the code below to try and explain.
> >
> >
> >
> >
> >
> >
> >
> > "<FormName>" is the name of the form you are calling this code from.
> It
> > can be found at the top of the tree view in the customization screen.
> >
> > This creates a session object that is needed to create the
> DynamicQuery
> > BO
> >
> > Dim episession As Session = CType(<FormName>, Session)
> >
> >
> >
> > Create the DynamicQuery BO
> >
> > Dim dqa As DynamicQuery = New DynamicQuery(episession.ConnectionPool)
> >
> >
> >
> > Pass the GetByID method the name of the BAQ that you want to call
> >
> > This will return a dataset that contains the details of the BAQ
> >
> > Dim ds As QueryDesignDataSet = dqa.GetByID("MATS-ProjectInfluencers")
> >
> >
> >
> > ***********************
> >
> > Only use these variables if you need to add criteria at runtime
> >
> >
> >
> > The name of your BAQ
> >
> > Dim pcQueryID as String = "MATS-ProjectInfluencers"
> >
> >
> >
> > The name of the table in your BAQ that you want to add a criteria
> > against
> >
> > Dim pcTable as String = "UD04"
> >
> >
> >
> > The field in the table above that will be used in your criteria
> >
> > Dim pcField as String = "Key1"
> >
> >
> >
> > The comparison operator for your criteria
> >
> > Dim pcCondition as String = "="
> >
> >
> >
> > Set to true if comparing to a constant value, false if comparing to
> > another field
> >
> > Dim pbIsConst as Boolean = true
> >
> >
> >
> > If above is true, the constant value
> >
> > Dim pcValue as String = "2010-0"
> >
> >
> >
> > If pbIsConst is false then this is the comparison table
> >
> > Dim pcToTable as String = String.Empty
> >
> >
> >
> > If pbIsConst is false then this is the comparison field
> >
> > Dim pcToField as String = String.Empty
> >
> >
> >
> > Do you want to set a left parentheses
> >
> > Dim pcLeftParentheses as String = String.Empty
> >
> >
> >
> > Do you want to set a right parentheses
> >
> > Dim pcRightParentheses as String = String.Empty
> >
> >
> >
> > If assigned more than one criteria, set the And or Or between the
> > criteria
> >
> > Dim pcAndOr as String = String.Empty
> >
> >
> >
> > Is this a negation criteria, same as checking the Not checkox
> >
> > Dim pbNeg as Boolean = false
> >
> >
> >
> > Calls AddWhereItem to add the criteria created above to BAQ dataset
> >
> > dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,
> >
> > pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,
> >
> > pcRightParentheses, pcAndOr, pbNeg)
> >
> > *******************************
> >
> >
> >
> > Execute the BAQ and store the results in a dataset
> >
> > Dim DQResults As DataSet = dqa.Execute(ds)
> >
> >
> >
> > Assign the dataset to an EpiUltraGrid
> >
> > ugInfluencers.DataSource = DQResults
> >
> >
> >
> > From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> [mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ] On
> Behalf
> > Of zanniebelle
> > Sent: Thursday, November 18, 2010 1:15 PM
> > To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> > Subject: [Vantage] Re: How To Call a BAQ from Customization Code?
> >
> >
> >
> >
> >
> > Thanks Joe for the reply.
> >
> > Can you provide a little more detail on the parameters and their
> > purpose?
> >
> > For example is "MATS-ProjectInfluencers" the BAQ your calling?
> >
> > Ray
> >
> > Any additional help is appreciated.
> >
> > --- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> <mailto:vantage%40yahoogroups.com> , Joe
> > Rojas <jrojas@> wrote:
> > >
> > > Here is an example that I posted a few months back
> > >
> > >
> > >
> > > Dim episession As Session = CType(<FormName>, Session)
> > >
> > >
> > >
> > > Dim dqa As DynamicQuery = New
> DynamicQuery(episession.ConnectionPool)
> > >
> > >
> > >
> > > Dim ds As QueryDesignDataSet =
> dqa.GetByID("MATS-ProjectInfluencers")
> > >
> > >
> > >
> > > Dim pcQueryID as String = "MATS-ProjectInfluencers"
> > >
> > >
> > >
> > > Dim pcTable as String = "UD04"
> > >
> > >
> > >
> > > Dim pcField as String = "Key1"
> > >
> > >
> > >
> > > Dim pcCondition as String = "="
> > >
> > >
> > >
> > > Dim pbIsConst as Boolean = true
> > >
> > >
> > >
> > > Dim pcValue as String = "2010-0"
> > >
> > >
> > >
> > > Dim pcToTable as String = String.Empty
> > >
> > >
> > >
> > > Dim pcToField as String = String.Empty
> > >
> > >
> > >
> > > Dim pcLeftParentheses as String = String.Empty
> > >
> > >
> > >
> > > Dim pcRightParentheses as String = String.Empty
> > >
> > >
> > >
> > > Dim pcAndOr as String = String.Empty
> > >
> > >
> > >
> > > Dim pbNeg as Boolean = false
> > >
> > >
> > >
> > > dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,
> > >
> > > pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,
> > >
> > > pcRightParentheses, pcAndOr, pbNeg)
> > >
> > >
> > >
> > > Dim DQResults As DataSet = dqa.Execute(ds)
> > >
> > >
> > >
> > > ugInfluencers.DataSource = DQResults
> > >
> > >
> > >
> > > From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> <mailto:vantage%40yahoogroups.com>
> > [mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> <mailto:vantage%40yahoogroups.com> ] On
> > Behalf
> > > Of zanniebelle
> > > Sent: Thursday, November 18, 2010 12:57 PM
> > > To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> <mailto:vantage%40yahoogroups.com>
> > > Subject: [Vantage] How To Call a BAQ from Customization Code?
> > >
> > >
> > >
> > >
> > >
> > > Hi All,
> > >
> > > Does anyone have an example of calling a BAQ from customization code
> > > that will fill a DataSet?
> > >
> > > Thanks,
> > >
> > > Ray
> > >
> > >
> > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
> [Non-text portions of this message have been removed]
>
Hi Joe,
I used your advice and got it to work. I added the criteria rows to the BAQ setting each field to ' '. Then I changed the value for each field in my method before calling Execute(see code below).

Thanks for you help!

Ray

private static void GetSignHistory(string as_custNum, string as_shipToNum, string as_partnum, string as_seq)
{
DynamicQuery dqa = new DynamicQuery(_session.ConnectionPool);
QueryDesignDataSet qdds = dqa.GetByID(SIGN_HISTORY_BAQ);

foreach (DataRow lo_row in qdds.QueryWhereItem.Rows)
{
switch (lo_row["FieldName"].ToString())
{
case "Key1":
lo_row["RValue"] = as_custNum;
break;
case "Key2":
lo_row["RValue"] = as_shipToNum;
break;
case "Key3":
lo_row["RValue"] = as_partnum;
break;
case "Key4":
lo_row["RValue"] = as_seq;
break;
}
}

DataSet ds = dqa.Execute(qdds);
epiUltraGridSignHistory.DataSource = ds;

}

--- In vantage@yahoogroups.com, Joe Rojas <jrojas@...> wrote:
>
> I think I remember having this issue but in my case I only had one
> criteria.
>
> The issue is that you can only have one new row at a time.
>
>
>
> In essence, you'd have to run Update(qdds) after each AddWhereItem.
>
> What I'm not sure about is if this will actually modify the BAQ on the
> server.
>
>
>
> Another approach would be to try and modify the RowMod field for the new
> criteria after the AddWhereItem runs.
>
> Something like: qds.Tables["QueryWhereItem"].Rows[0]["RowMod"] = ""
>
> You'd have to change Rows[0] to the last number plus 1 (e.g. 0, 1, 2, 3)
>
>
>
> Lastly, you could define the criteria directly in the BAQ for Key 1 to
> Key 4 and set each on equal "", then after you retrieve the BAQ dataset,
> modify each only using a similar syntax as above.
>
>
>
> Just spit balling here.
>
>
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> Of zanniebelle
> Sent: Thursday, November 18, 2010 4:08 PM
> To: vantage@yahoogroups.com
> Subject: [Vantage] Re: How To Call a BAQ from Customization Code?
>
>
>
>
>
> Hi Joe,
> I have tried to get this to work and I am able to call the BAQ, but it
> seems that I can only add one WhereItem. When I add more than one only
> the last one added affects the results. Do you see anything I'm doing
> wrong here?
>
> private static void GetSignHistory(string as_custNum, string
> as_shipToNum, string as_partnum, string as_seq)
> {
> DynamicQuery dqa = new DynamicQuery(_session.ConnectionPool);
> QueryDesignDataSet qdds = dqa.GetByID(SIGN_HISTORY_BAQ);
>
> string ls_queryId = SIGN_HISTORY_BAQ;
> string ls_table = "UD09";
> string ls_field = "Key1";
> string ls_condition = "=";
> string ls_empty = String.Empty;
> bool lb_isConst = true;
>
> dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
> st,as_custNum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);
>
> ls_field = "Key2";
> dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
> st,as_shipToNum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);
>
> ls_field = "Key3";
> dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
> st,as_partnum,ls_empty,ls_empty,ls_empty,ls_empty,"And",false);
>
> ls_field = "Key4";
> dqa.AddWhereItem(qdds,ls_queryId,ls_table,ls_field,ls_condition,lb_isCon
> st,as_seq,ls_empty,ls_empty,ls_empty,ls_empty,"",false);
>
> DataSet ds = dqa.Execute(qdds);
> epiUltraGridSignHistory.DataSource = ds;
>
> }
>
> The results all have the same sequence (as_seq) number, but different
> part numbers and shipto numbers.
>
> If I comment out the last AddWhereItem the results only contains records
> where there is a partnumber match (as_partNum)
>
> Any help you can provide is appreciated!
>
> Thanks,
>
> Ray
>
> --- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> , Joe
> Rojas <jrojas@> wrote:
> >
> > Sorry, I was in a rush but I wanted to give you an answer.
> >
> > I decided to work with the BO instead of the adapter. If you're
> familiar
> > with working in the BAQ designer, some of these parameters should be
> > familiar.
> >
> > The example I gave is if you want to add criteria to your BAQ at
> > runtime. However, if you just want to call a BAQ without adding
> criteria
> > at runtime, then you can just call the ExexcuteByID method instead.
> >
> > I'll comment in the code below to try and explain.
> >
> >
> >
> >
> >
> >
> >
> > "<FormName>" is the name of the form you are calling this code from.
> It
> > can be found at the top of the tree view in the customization screen.
> >
> > This creates a session object that is needed to create the
> DynamicQuery
> > BO
> >
> > Dim episession As Session = CType(<FormName>, Session)
> >
> >
> >
> > Create the DynamicQuery BO
> >
> > Dim dqa As DynamicQuery = New DynamicQuery(episession.ConnectionPool)
> >
> >
> >
> > Pass the GetByID method the name of the BAQ that you want to call
> >
> > This will return a dataset that contains the details of the BAQ
> >
> > Dim ds As QueryDesignDataSet = dqa.GetByID("MATS-ProjectInfluencers")
> >
> >
> >
> > ***********************
> >
> > Only use these variables if you need to add criteria at runtime
> >
> >
> >
> > The name of your BAQ
> >
> > Dim pcQueryID as String = "MATS-ProjectInfluencers"
> >
> >
> >
> > The name of the table in your BAQ that you want to add a criteria
> > against
> >
> > Dim pcTable as String = "UD04"
> >
> >
> >
> > The field in the table above that will be used in your criteria
> >
> > Dim pcField as String = "Key1"
> >
> >
> >
> > The comparison operator for your criteria
> >
> > Dim pcCondition as String = "="
> >
> >
> >
> > Set to true if comparing to a constant value, false if comparing to
> > another field
> >
> > Dim pbIsConst as Boolean = true
> >
> >
> >
> > If above is true, the constant value
> >
> > Dim pcValue as String = "2010-0"
> >
> >
> >
> > If pbIsConst is false then this is the comparison table
> >
> > Dim pcToTable as String = String.Empty
> >
> >
> >
> > If pbIsConst is false then this is the comparison field
> >
> > Dim pcToField as String = String.Empty
> >
> >
> >
> > Do you want to set a left parentheses
> >
> > Dim pcLeftParentheses as String = String.Empty
> >
> >
> >
> > Do you want to set a right parentheses
> >
> > Dim pcRightParentheses as String = String.Empty
> >
> >
> >
> > If assigned more than one criteria, set the And or Or between the
> > criteria
> >
> > Dim pcAndOr as String = String.Empty
> >
> >
> >
> > Is this a negation criteria, same as checking the Not checkox
> >
> > Dim pbNeg as Boolean = false
> >
> >
> >
> > Calls AddWhereItem to add the criteria created above to BAQ dataset
> >
> > dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,
> >
> > pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,
> >
> > pcRightParentheses, pcAndOr, pbNeg)
> >
> > *******************************
> >
> >
> >
> > Execute the BAQ and store the results in a dataset
> >
> > Dim DQResults As DataSet = dqa.Execute(ds)
> >
> >
> >
> > Assign the dataset to an EpiUltraGrid
> >
> > ugInfluencers.DataSource = DQResults
> >
> >
> >
> > From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> [mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ] On
> Behalf
> > Of zanniebelle
> > Sent: Thursday, November 18, 2010 1:15 PM
> > To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> > Subject: [Vantage] Re: How To Call a BAQ from Customization Code?
> >
> >
> >
> >
> >
> > Thanks Joe for the reply.
> >
> > Can you provide a little more detail on the parameters and their
> > purpose?
> >
> > For example is "MATS-ProjectInfluencers" the BAQ your calling?
> >
> > Ray
> >
> > Any additional help is appreciated.
> >
> > --- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> <mailto:vantage%40yahoogroups.com> , Joe
> > Rojas <jrojas@> wrote:
> > >
> > > Here is an example that I posted a few months back
> > >
> > >
> > >
> > > Dim episession As Session = CType(<FormName>, Session)
> > >
> > >
> > >
> > > Dim dqa As DynamicQuery = New
> DynamicQuery(episession.ConnectionPool)
> > >
> > >
> > >
> > > Dim ds As QueryDesignDataSet =
> dqa.GetByID("MATS-ProjectInfluencers")
> > >
> > >
> > >
> > > Dim pcQueryID as String = "MATS-ProjectInfluencers"
> > >
> > >
> > >
> > > Dim pcTable as String = "UD04"
> > >
> > >
> > >
> > > Dim pcField as String = "Key1"
> > >
> > >
> > >
> > > Dim pcCondition as String = "="
> > >
> > >
> > >
> > > Dim pbIsConst as Boolean = true
> > >
> > >
> > >
> > > Dim pcValue as String = "2010-0"
> > >
> > >
> > >
> > > Dim pcToTable as String = String.Empty
> > >
> > >
> > >
> > > Dim pcToField as String = String.Empty
> > >
> > >
> > >
> > > Dim pcLeftParentheses as String = String.Empty
> > >
> > >
> > >
> > > Dim pcRightParentheses as String = String.Empty
> > >
> > >
> > >
> > > Dim pcAndOr as String = String.Empty
> > >
> > >
> > >
> > > Dim pbNeg as Boolean = false
> > >
> > >
> > >
> > > dqa.AddWhereItem(ds, pcQueryID, pcTable, pcField, pcCondition,
> > >
> > > pbIsConst, pcValue, pcToTable, pcToField, pcLeftParentheses,
> > >
> > > pcRightParentheses, pcAndOr, pbNeg)
> > >
> > >
> > >
> > > Dim DQResults As DataSet = dqa.Execute(ds)
> > >
> > >
> > >
> > > ugInfluencers.DataSource = DQResults
> > >
> > >
> > >
> > > From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> <mailto:vantage%40yahoogroups.com>
> > [mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> <mailto:vantage%40yahoogroups.com> ] On
> > Behalf
> > > Of zanniebelle
> > > Sent: Thursday, November 18, 2010 12:57 PM
> > > To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> <mailto:vantage%40yahoogroups.com>
> > > Subject: [Vantage] How To Call a BAQ from Customization Code?
> > >
> > >
> > >
> > >
> > >
> > > Hi All,
> > >
> > > Does anyone have an example of calling a BAQ from customization code
> > > that will fill a DataSet?
> > >
> > > Thanks,
> > >
> > > Ray
> > >
> > >
> > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
> [Non-text portions of this message have been removed]
>