Customization Code to run a Criteria Report not a BAQ report

I am trying to, from a button, launch a report with criteria selected from the report. I am hitting a wall. Most documentation I find is for a BAQ report. I created this report using RDD and it runs with SSRS Breaking/Routing rules. I tried to follow this post, but it doesn’t work anymore. C# Help with DynamicCriteria Report

Any nudge in the right direction is appreciated. Currently I have the code launching a BAQ, which does half of what I want, but I need to get the report to trigger.

If you can find an existing menu location for the report you’re trying to launch, you can do it by Launching the Form through the button click. Here is an example of where I use an Actions menu click to launch the BOM Listing report from Method Tracker using the parameters of the revision I have loaded in Method Tracker. I imagine you could do something similar.

	private void BOMListing_ToolClick(object sender,Infragistics.Win.UltraWinToolbars.ToolClickEventArgs args)
		string partNum = this.edvECORev.dataView[this.edvECORev.Row]["PartNum"].ToString();
		string revision = this.edvECORev.dataView[this.edvECORev.Row]["RevisionNum"].ToString();

		if (!String.IsNullOrEmpty(partNum) && !String.IsNullOrEmpty(revision))
			LaunchFormOptions lfo = new LaunchFormOptions();
			lfo.IsModal = true;
			lfo.ValueIn = partNum + "~" + revision;   
			ProcessCaller.LaunchForm(oTrans, "SEMN4020", lfo);
			string NoPartMessage = "No part number and/or revision available.";
			string NoPartCaption = "BOM Listing Not Available";
			MessageBox.Show(NoPartMessage, NoPartCaption, MessageBoxButtons.OK);

Ok this may work. I am looking for a way to run this without further user interaction. Will this allow me to launch the form and submit the report without the user being able to stop the process? If not, I’ll work with it. I have a similar button in quotes that populates the variables and allows the user to run a report, but for this one, I was hoping to have the button be the last interaction from the user.

You should be able to do this… but what I pasted up there will still require the user to click the print preview to get the form. Depending on the form, you might be able to pass some parameters using the launch form options telling it to RunDirect or something like that… and if that doesn’t work, you can customize the print dialog to tell it to print and then close the screen without a user interaction. I have used both ways and I don’t remember why one way had to be used vs. the other.

Perfect, I’ll give this a shot and post the final solution when I get it sorted. Thank you.

I ended up having the form close itself after ‘printing’. It works. It does ask if you want to run the break/routing rules, but I can live with that.

private void DynamicCriteriaReportForm_Load(object sender, EventArgs args)
		// Add Event Handler Code

		if (DynamicCriteriaReportForm.LaunchFormOptions != null && DynamicCriteriaReportForm.LaunchFormOptions.Sender != null)
			EpiNumericEditor numOrderNum_1 = (EpiNumericEditor)csm.GetNativeControlReference("78f1864b-7dc8-4145-931d-c1d6a2b10bdd");			  		

  		  object ctxValue = DynamicCriteriaReportForm.LaunchFormOptions.ContextValue;
			string[] values = ctxValue.ToString().Split(','); // Split string
			EpiDataView dvRP = (EpiDataView)oTrans.EpiDataViews["ReportCriteria"];
			string workID = oTrans.WorkStationID.ToString();
			EpiDataView ds = (EpiDataView)(oTrans.EpiDataViews["ReportParam"]);
			var EnableRouting = ds.dataView[ds.Row]["SSRSEnableRouting"];
			var AutoAction = ds.dataView[ds.Row]["AutoAction"];
			var RSN = ds.dataView[ds.Row]["ReportStyleNum"];			
			EnableRouting = true;
			AutoAction = "SSRSPREVIEW";
			RSN = 1001;
			dvRP.dataView[dvRP.Row]["OrderNum_1"] = int.Parse(values[0]);
			numOrderNum_1.Value = int.Parse(values[0]);
		oTrans.SubmitToAgent("SystemTaskAgent", 0,0);
		oTrans.PushDisposableStatusText("Reports Submitted for Preview...", true);

In my case
EpiDataView dvRP = (EpiDataView)oTrans.EpiDataViews[“ReportCriteria”];

dvRP is null and thus giving error.
Can you please guide?

If it is a Dynamic criteria report with criteria then it shouldn’t be null. Are you running this code on the Customization of the Report itself? I’ll give you a run down of my entire process, hopefully it can assist.

First my customization is on a button on the quote form that sets the criteria on the Dynamic Criteria Report form.

private void epiButtonBOM_Click(object sender, System.EventArgs args)
		// ** Place Event Handling Code Here **
		EpiTextBox QuotNum = (EpiTextBox)csm.GetNativeControlReference("8e25166f-6185-4497-b3d6-1798e4e9c4a0");
		EpiUltraComboPlus LineNum = (EpiUltraComboPlus)csm.GetNativeControlReference("fa359824-fd06-42b4-9f2c-e31d23d4f97e");
		string currentQtNum=QuotNum.Text;
		string currentLineNum=LineNum.EpiCombo.Text;
		string[] prtParams = {currentQtNum, currentLineNum };
		LaunchFormOptions lfo = new LaunchFormOptions();
		lfo.IsModal = true;
		lfo.ContextValue=currentQtNum +","+currentLineNum; // Make string values delimited
		ProcessCaller.LaunchForm(oTrans, "JTibom",lfo); //the menu id


Then the rest of my code is actually on a customization on the menu item “JTibom”. It’s been to long, so I don’t recall if I needed to add a reference or not, but if I did it would be the Ice.UIRpt.DynamicCriteriaReport. Since this is a closed topic, you may want to start a new one, but I do think that adding this clarifies how I executed this.

it worked , Thank you . but now

oTrans.SubmitToAgent("SystemTaskAgent", 0,0);
is giving error invalid task agent.
Am i missing something?

Run a trace in tracing options and run a report, then look for in the trace log for the SubmitToAgent and find the agentSchedNum and the agentTaskNum. Mine is 0, 0. Then just change the SystemTaskAgent line to match.

  <localTime>8/24/2023 09:14:27:6953455 AM</localTime>
  <executionTime total="153" roundTrip="152" channel="0" bpm="0" bpmDataForm="0" other="1" />
    <parameter name="ds" type="Erp.Rpt.JobStatusReportDataSet">
      <JobStatusReportDataSet xmlns="" />
    <parameter name="agentID" type="System.String"><![CDATA[SystemTaskAgent]]></parameter>
    <parameter name="agentSchedNum" type="System.Int64"><![CDATA[0]]></parameter>
    <parameter name="agentTaskNum" type="System.Int32"><![CDATA[0]]></parameter>
    <parameter name="maintProgram" type="System.String"><![CDATA[Erp.UIRpt.JobStatusReport]]></parameter>