Calling Advanced BAQ Report with Parameter from button

I have an Advanced BAQ report written in Kinetic 2023. By “Advanced”, meaning I created a BAQ with parameters, created the RDD with the BAQ as the data source, set up the parameters in the RDD, then created the report style. I’ve added that report as a menu item and I’m able to run the menu item directly with no problems.

However, I’ve got a process where I’ve got a button in a standard entry form (DMR Processing) running in the classic interface. The idea is you press the button, it calls the menu item and passed the DMR number to the dialog box, and the user gets the report item up with the parameter already entered. This worked fine when the report was a standard BAQ report (created via the BAQ Report menu item). I used the launch form options in the calling program to pass the parameter to the menu item for the report, and the menu item pulled the parameter and filled it on the screen.

When I converted this from a standard BAQ report to an advanced BAQ report, the launching of the report via the menu item no longer works properly. (I want the advanced BAQ report because you can run that ALL-Company, that feature is not available with standard BAQ reports.) So, I have menu item UDDMRRPT which runs the report. When I run UDDMRRPT, it comes up with the parameter on the screen, the report style is set, etc. If I execute the following command from DMR Processing: ProcessCaller.LaunchForm(oTrans, “UDDMRRPT”, “UDDMRRPT”);
this doesn’t appear to even be running the same menu option. The parameter is not on the screen, the report style is blank, even the title bar on the window is different. Note that I’m not even trying to pass parameters at this point, just getting it to invoke the report.

So, anybody have any luck calling a menu item that runs an Advanced BAQ Report with parameters? Alternatively, I’m guessing that I can call the report directly from a button and pass the parameter, rather than calling a menu item which calls the report?

My Plan B for this is to mess with autoprinting, do something on the button that will invoke the autoprint where I can set the parameter in the data directive.

TIA,
Kevin

I am not sure but I have this bit of code that passes parameters from your customization into your BAQ:

	private void getRevs()
	{
		cmbpartrev = (Ice.Lib.Framework.EpiUltraCombo)csm.GetNativeControlReference("8ba6336e-50bb-4814-9f5d-4c85237c4f81");

		DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
		dqa.BOConnect();		
		QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("getPartRev");
		qeds.ExecutionParameter.Clear();

		qeds.ExecutionParameter.AddExecutionParameterRow("part", myPart.Text, "nvarchar", false, Guid.NewGuid(), "A");

		dqa.ExecuteByID("getPartRev", qeds);
		if (dqa.QueryResults.Tables["Results"].Rows.Count > 0)
		{
			cmbpartrev.DataSource = dqa.QueryResults.Tables["Results"];
			cmbpartrev.DisplayMember = "PartRev_RevisionNum";
			cmbpartrev.ValueMember = "PartRev_RevisionNum";
			oTrans.NotifyAll();
		}
	}

In this case the parameter value for “part” number is pulled from the myPart.Text box. The BAQ “getPartRev” is then run with the new parameter, and results are passed into a combobox of part revisions.
I hope this helps some! Good luck!

Nate,

That’s a good snippet of code! That is code that would return the results of the BAQ into a dataset for use in the calling program (such as displaying in a grid). I’ve trying to invoke an SSRS report that’s based on a BAQ/Parameter.

:thinking:

Here’s an example of something we did:

First setup the prompts in the RDD

Then setup the LaunchFormOptions. We have a button on a dashboard that launch the report.

	private void btnPrintPickListRpt_Click(object sender, System.EventArgs args)
	{
		string key1 = Convert.ToString(edvCallContext.CurrentDataRow["Character01"]);
		string opCode = Convert.ToString(edvCallContext.CurrentDataRow["Character05"]);
		string phase = Convert.ToString(edvCallContext.CurrentDataRow["Character04"]);
		
		if(string.IsNullOrEmpty(key1)) return;

		System.Collections.Generic.Dictionary<string, string> contextValueList = new System.Collections.Generic.Dictionary<string, string>();

		contextValueList.Add("CsNum", key1);
		contextValueList.Add("OpCode", opCode);
		contextValueList.Add("Phase", phase);

        LaunchFormOptions lfo = new LaunchFormOptions();
	    lfo.ContextValue = contextValueList;
        ProcessCaller.LaunchForm(oTrans,"PL002",lfo);
	}

And finally handle the LaunchFormOptions in the print form customization

	private void DynamicCriteriaReportForm_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code
		if(DynamicCriteriaReportForm.LaunchFormOptions != null && DynamicCriteriaReportForm.LaunchFormOptions.ContextValue != null)
		{
			System.Collections.Generic.Dictionary<string, string> contextValueList = (System.Collections.Generic.Dictionary<string, string>)DynamicCriteriaReportForm.LaunchFormOptions.ContextValue;
			
			string csnum = contextValueList["CsNum"];
			string opCode = contextValueList["OpCode"];
			string phase = contextValueList["Phase"];
			
			EpiDataView edvReportCriteria = (EpiDataView)(oTrans.EpiDataViews["ReportCriteria"]);
			edvReportCriteria.CurrentDataRow.BeginEdit();
			edvReportCriteria.CurrentDataRow["UD02_Key1_3"] = csnum;
			edvReportCriteria.CurrentDataRow["OpCode_1"] = opCode;
			edvReportCriteria.CurrentDataRow["Phase_2"] = phase;
			edvReportCriteria.CurrentDataRow.EndEdit();

		}
	}

Here is the end result:

2 Likes

Worked great! Thanks.

why?
private void prink_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
string key1 = Convert.ToString(edvCallContext.CurrentDataRow[“key1”]);
if(string.IsNullOrEmpty(key1)) return;

	System.Collections.Generic.Dictionary<string, string> contextValueList = new System.Collections.Generic.Dictionary<string, string>();

	contextValueList.Add("key", key1);
    LaunchFormOptions lfo = new LaunchFormOptions();
    lfo.ContextValue = contextValueList;
    ProcessCaller.LaunchForm(oTrans,"UD04",lfo);
}

}
Compiling Custom Code …

----------errors and warnings------------

Error: CS0103 - line 58 (333) - 当前上下文中不存在名称“edvCallContext”

** Compile Failed. **

EpiDataView edvReportCriteria = (EpiDataView)(oTrans.EpiDataViews[“ReportCriteria”]);

edvReportCriteria is null so it is giving an error.
Can you please guide?

What is the name of the form in which you ran that line of code ?
image

Same as you mentioned
image

Good, now please show us the entire code and the actual error message.

it worked ,i was passing wrong values. Thank you.
but there is another issue. i want to print without preview button click
edvReportCriteria.CurrentDataRow.BeginEdit();
edvReportCriteria.CurrentDataRow[“QuoteNumber_2”] = int.Parse(values[0]);
edvReportCriteria.CurrentDataRow[“QuoteLine_1”] = int.Parse(values[1]);
edvReportCriteria.CurrentDataRow.EndEdit();
oTrans.SubmitToAgent(“SystemTaskAgent”, 0,0);

oTrans.SubmitToAgent(“SystemTaskAgent”, 0,0); is giving error invalid task agent.
Appreciate your help.

Refer to this post for that issue.