Dashboard Pass Silent Parameters to BAQ

Trying to figure out a way to overcome this “temporary” limitation, I have come to the below workaround that works for both Dashboards and BAQ Reports (in a short different way but the key concept is the same).

  1. Add some UD Fields to UDCodes table. These will be used to hold the values that your BAQ will use instead of parameters. i.e.

  1. Modify your BAQ so that instead of adding a Parameter as Criteria, Join the UDCodes table and add a relation to the field that will contain the value you would normaly use as Parameter. Also select at the Display Fields the CodeID from the UD Codes.

  1. Create the Dashboard as usual, include at the tracker the UDCode.CodeID field and deploy as Smart Client Application

  1. Now , what we need is to auto-create the UDCode record (before the BAQ is executed) that will store our “Parameter” values. Create a Dashboard Assembly menu item for the Dashboard and enter customization mode.

  2. Add any Controls (not need to be bound somewhere) that will hold the “Parameter” values , in my case the InvoiceNum, you can hide the CodeID textbox and label.

  1. Add the following code to Create the UDCode Record before the BAQ is executed, also remove the UDcode record just after the Execution.
public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	private DataView V_BAQTestParams_1View_DataView;
	private string codeTypeID = "BAQParams";					
	private string codeID = "";
	private EpiDataView edvV_BAQTestParams_1View;
	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization
		
		this.baseToolbarsManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
		this.V_BAQTestParams_1View_DataView = this.V_BAQTestParams_1View_Row.dataView;
		this.edvV_BAQTestParams_1View = ((EpiDataView)(this.oTrans.EpiDataViews["V_BAQTestParams_1View"]));
		this.edvV_BAQTestParams_1View.EpiViewNotification += new EpiViewNotification(this.edvV_BAQTestParams_1View_EpiViewNotification);
		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		// End Wizard Added Custom Method Calls
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal
		
		this.baseToolbarsManager.ToolClick -= new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(this.baseToolbarsManager_ToolClick);
		this.V_BAQTestParams_1View_DataView = null;
		this.edvV_BAQTestParams_1View.EpiViewNotification -= new EpiViewNotification(this.edvV_BAQTestParams_1View_EpiViewNotification);
		this.edvV_BAQTestParams_1View = null;
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}


	private void baseToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs args)
	{
		if(args.Tool.Key.Equals("RefreshTool"))
			AddUserCodeRecordForBAQ();
	}

	private void AddUserCodeRecordForBAQ()
	{
		try
		{
			// Declare and Initialize EpiDataView Variables
			// Declare and create an instance of the Adapter.
			if(txtInvoiceNum.Text.Equals(""))
				return;

			EpiDataView edvDashBoardParam = ((EpiDataView)(this.oTrans.EpiDataViews["V_BAQTestParams_1View"]));		
			UserCodesAdapter adapterUserCodes = new UserCodesAdapter(this.oTrans);
			adapterUserCodes.BOConnect();
								

			adapterUserCodes.GetByID(codeTypeID);
			if(adapterUserCodes.UserCodesData.UDCodeType.Rows.Count > 0)
			{
				bool result = adapterUserCodes.GetNewUDCodes(codeTypeID);
				if(result)
				{
					DataRow[] DrUD = adapterUserCodes.UserCodesData.UDCodes.Select("RowMod = 'A'");					
					DrUD[0]["CodeDesc"] = txtInvoiceNum.Text;
					DrUD[0]["Char01_c"] = txtInvoiceNum.Text;
					codeID = DrUD[0]["CodeID"].ToString();
				}
				adapterUserCodes.Update();
			}
			// Cleanup Adapter Reference
			adapterUserCodes.Dispose();			
			((EpiTextBox)csm.GetNativeControlReference("ddce9075-b1d1-4166-b354-9bc446498eb1")).Text = codeID;			

		} catch (System.Exception ex)
		{
			ExceptionBox.Show(ex);
		}
	}
	

	private void edvV_BAQTestParams_1View_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
	{
		// ** Argument Properties and Uses **
		// view.dataView[args.Row]["FieldName"]
		// args.Row, args.Column, args.Sender, args.NotifyType
		// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
		if ((args.NotifyType == EpiTransaction.NotifyType.Initialize) && codeID != "")
		{		
			try
			{			
			UserCodesAdapter adapterUserCodes = new UserCodesAdapter(this.oTrans);
			adapterUserCodes.BOConnect();
						

			adapterUserCodes.GetByID(codeTypeID);
			if(adapterUserCodes.UserCodesData.UDCodeType.Rows.Count > 0)
			{
				DataRow[] DrUD = adapterUserCodes.UserCodesData.UDCodes.Select("CodeID = '" + codeID + "'");
				if(DrUD.Length > 0)									
				{					
					DrUD[0]["RowMod"] = "D";	
					adapterUserCodes.Delete(DrUD[0]);				
				}
				//adapterUserCodes.Update();
			}
			// Cleanup Adapter Reference
			adapterUserCodes.Dispose();	
			codeID = "";

			} catch (System.Exception ex)
			{
				ExceptionBox.Show(ex);
			}
		}	
	}
}

3 Likes