Customization With BAQ

So I created a BAQ that looks at change log (chglog table) to pull first date that a job is released and put that into Job Entry. It is working, but I have another company with the same JobNum that the chglog has not been setup for it yet. When I pull that job in JobEntry, it is pulling the date from the other company.

Here’s a snippet of my code. In my BAQ I am using the Company and JobNum as the parameter. Shouldn’t it be pulling a blank instead of the first released date from another company?

private void edvJobHead_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
	{
		if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
		{
			if ((args.Row > -1))
			{
	
			
				EpiDataView edvJobHead=(EpiDataView)oTrans.EpiDataViews["JobHead"];
				jobNum = edvJobHead.dataView[edvJobHead.Row]["JobNum"].ToString();
				company = edvJobHead.dataView[edvJobHead.Row]["Company"].ToString();

				
				string BAQName = "JobRelDate";
				Ice.BO.QueryExecutionDataSet ds = new Ice.BO.QueryExecutionDataSet();
				
			
				ds.ExecutionParameter.AddExecutionParameterRow("JobNum", jobNum, "nvarchar", false, Guid.Empty, "A");
				ds.ExecutionParameter.AddExecutionParameterRow("Company", company, "nvarchar", false, Guid.Empty, "A");

				
				Ice.Proxy.BO.DynamicQueryImpl dynamicQuery = WCFServiceSupport.CreateImpl<Ice.Proxy.BO.DynamicQueryImpl>((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.DynamicQuerySvcContract>.UriPath);
				System.Data.DataSet results = dynamicQuery.ExecuteByID(BAQName, ds);

				
				if(results.Tables["Results"].Rows.Count > 0)
				{
					foreach (DataRow item in results.Tables["Results"].Rows)
					{
						string val = item["Calculated_DateStampedOn"].ToString();
						dteDateRel.Text = val;
					}

				}
				else
				{
					dteDateRel.Text = string.Empty;
				}
			}


		}
	}

When I test my BAQ, if I put in the Company ID and JobNum, it is showing up blank. So I am thinking maybe my parameter isn’t working with Company from my C# customization? BAQ is working correctly.

Sounds like you are over complicating things. If you must use a BAQ, don’t use “cross company”. However, if you are using code, can’t you use linq to directly query the ChgLog table instead of using a BAQ?

As far as I’m aware, client customization code doesn’t have the same connections to the database as BPMs do. You would have to initialize and connect to the business objects for any object/table you want to use in the query, rather than just connecting to the BAQ object and calling the BAQ. Granted, if the only tables that are involved are JobHead and ChgLog, this wouldn’t be too much of a hassle to set up.

@changchai Try using MessageBox.Show() to make sure the company value you’re getting from the JobHead object is what you are expecting, and what the BAQ is expecting. You can also try setting the BAQ up in a dashboard and testing it from there to make sure it’s not a difference in behavior inside the BAQ editor (it shouldn’t, but it’s good to be sure).

Sorry, I misread the code. I assumed this was a BPM (probably shouldn’t read too much code from my phone…
However, yes, a BAQ is fine here, however, I would use a BAQView instead. Do a search on this site for BAQView and you will have a lot less code and much faster access.

1 Like

Thank you both for the input. What I end up doing with the BAQ is add a filter for CurrentCompany. This seems to be working correctly now. I will take a look at BAQView as well.