I’m trying to create a BPM to run a BAQ, get a result, and paste that into a field on the QuoteHed Table. I’m not a coder, so most of what I have I pieced together from other posts on here.
When ran in isolation, it calls the BAQ, finds the correct value, and I can put it in an info message. Giving the parameter the quote number is where I’m having issues. (Currently I have it typed in for testing).
var tempQuoteDtl = (from row in ds.QuoteDtl where row.Company == Session.CompanyID && (row.RowMod == "A" || row.RowMod == "U") select row).FirstOrDefault();
if(tempQuoteDtl != null)
{
int QuoteNum = Convert.ToInt32(tempQuoteDtl.QuoteNum);
InfoMessage.Publish("test1");
var tempQuoteHed = (from row in ds.QuoteHed where row.Company == Session.CompanyID && row.QuoteNum == QuoteNum && (row.RowMod == "A" || row.RowMod == "U") select row).FirstOrDefault();
if(tempQuoteHed != null)
{
InfoMessage.Publish("test2");
int QuoteNum = Convert.ToInt32(tempQuoteHed.QuoteNum);
Ice.Contracts.DynamicQuerySvcContract tQuery = Ice.Assemblies.ServiceRenderer.GetService<Ice.Contracts.DynamicQuerySvcContract>(Db);
if (tQuery != null)
{
Ice.Tablesets.DynamicQueryTableset dsQuery = tQuery.GetByID("QuoteCost");
if (dsQuery != null)
{
Ice.Tablesets.QueryExecutionTableset dsBAQ = tQuery.GetQueryExecutionParameters(dsQuery);
dsBAQ.ExecutionParameter[0].ParameterID = "QuoteNum";
dsBAQ.ExecutionParameter[0].IsEmpty = false;
dsBAQ.ExecutionParameter[0].ParameterValue = "96325";
DataSet result = tQuery.Execute(dsQuery, dsBAQ);
tempQuoteHed.QuoteCost_c = Convert.ToDecimal(result);
foreach(DataRow row in result.Tables[0].Rows)
{
var quoteCost = row["Calculated_TotalCost"];
InfoMessage.Publish(Convert.ToString(tempQuoteHed.QuoteCost_c));
}
dsBAQ = null;
}
dsQuery = null;
tQuery.Dispose();
}
}
}
Good morning!
I made this change, but the BPM doesn’t seem to even run (this is not due to the change made, it never ran before). I have a line:
InfoMessage.Publish(“test1”);
This does not appear when testing.
This line must be returning as null, but I don’t know why
var tempQuoteDtl = (from row in ds.QuoteDtl where row.Company == Session.CompanyID && (row.RowMod == "A" || row.RowMod == "U") select row).FirstOrDefault();
if(tempQuoteDtl != null)
{
Assuming that this is a method directive - (1) what method are you running this on and (2) what actions are you taking in the UI that you are expecting this BPM to run?
This is on the Quote Update method. I’m testing it by writing messages with key info throughout the code, so I know where it fails. I go to a quote, change a PO number and save to proc the update method.
This is the current state of the code:
var tempQuoteHed = (from row in ds.QuoteHed where row.Company == Session.CompanyID /*&& (row.RowMod == "A" || row.RowMod == "U")*/ select row).FirstOrDefault();
if(tempQuoteHed != null)
{
int QuoteNum = Convert.ToInt32(tempQuoteHed.QuoteNum);
InfoMessage.Publish(Convert.ToString(QuoteNum));
Ice.Contracts.DynamicQuerySvcContract tQuery = Ice.Assemblies.ServiceRenderer.GetService<Ice.Contracts.DynamicQuerySvcContract>(Db);
if (tQuery != null)
{
Ice.Tablesets.DynamicQueryTableset dsQuery = tQuery.GetByID("QuoteCost");
if (dsQuery != null)
{
Ice.Tablesets.QueryExecutionTableset dsBAQ = tQuery.GetQueryExecutionParameters(dsQuery);
dsBAQ.ExecutionParameter[0].ParameterID = "QuoteNum";
dsBAQ.ExecutionParameter[0].IsEmpty = false;
dsBAQ.ExecutionParameter[0].ParameterValue = QuoteNum.ToString();
DataSet result = tQuery.Execute(dsQuery, dsBAQ);
//ttRecord["QuoteCost_c"] = Convert.ToDecimal(result);
foreach(DataRow row in result.Tables[0].Rows)
{
var quoteCost = row["Calculated_TotalCost"];
InfoMessage.Publish(Convert.ToString(quoteCost));
tempQuoteHed.QuoteCost_c = quoteCost; //ISSUES HERE
}
dsBAQ = null;
}
dsQuery = null;
tQuery.Dispose();
}
}
I’m having issues with setting the results of the BAQ into a field on the QuoteHed table, QuoteCost_c.
Error message: ‘QuoteHedRow’ does not contain a definition for ‘QuoteCost_c’ and no accessible extension method ‘QuoteCost_c’ accepting a first argument of type ‘QuoteHedRow’ could be found (are you missing a using directive or an assembly reference?)
Upon checking the QuoteHed table, QuoteCost_c is definitely there, and the tables are sync’d via DMR.
I have tried this!
I am getting the correct number, and no errors. When I test, everything indicates that it works fine, but a BAQ still shows the value as 0.
I am coding all this in a Post-Process update
Dave
are you trying to get the value that is being just set in the method? maybe you are trying to get data before transaction is complete yet and they are not avaialble
I’ve changed it to a pre-process and tested. I also added the field to the header for better clarification.
It’s still popping up messages with the correct data, pulled from the BAQ. However, it’s still not saving. I even changed the field itself (QuoteCost_c) to some arbitrary number and saved to proc the update method. It went back to 0.00.