I am trying to add 2 fields to the ‘Shipments’ grid in Customer Tracker/Entry in the ‘Activity’ section.
Specifically the Unit Price of the part associated with the OrderDtl line in the PackId/Line and a calculated field which is just that unit price * the total quantity shipped.
I tried the ‘Version 2’ method as it seemed appropriate because I liked the idea of creating a BAQ to get the columns I needed and associate them with the existing grid.
Following a guide is one thing, but as soon as it doesn’t work I quickly feel over my head when I try and understand if/where I am going wrong.
I also see that using a BPM is the preferred method to achieve this. Not sure if this method is appropriate because I am not trying to the the exact thing as it is laid out in that guide.
@hackaphreaka I’ve had good success overriding the load event and passing the DataView to a Function. The DataView comes into the Function as a C# DataSet object.
Check for data.
Add the extra column(s) to the DataSet.
Set up a couple variables to hold foreign key data from your original DataSet.
Loop through the rows or your original DataSet.
Make a LINQ or LAMDA query to the related table(s) based on your foreign key(s) to retrieve your extra data.
Add the desired fields in into your newly created column.
Return the updated DataSet which App Studio can readily use as a DataView for the grid.
Works like a charm!
Here’s an example adding order term codes to the pack slip browse grid so AR knows which shipments to invoice.
try
{
//string sMsg = "dsIn.Tables.Count: " + dsIn.Tables.Count.ToString() + "\r\n";
if(dsIn.Tables.Count > 0)
{
dsIn.Tables[0].Columns.Add("TermsCode", typeof(string));
int iOrderNum = 0;
//sMsg += "dsIn.Tables[0].Rows.Count: " + dsIn.Tables[0].Rows.Count.ToString() + "\r\n";
foreach(DataRow dr in dsIn.Tables[0].Rows)
{
Int32.TryParse(dr["SalesOrder"].ToString(), out iOrderNum);
var OrderRow = (from tc in Db.OrderHed
where tc.Company == Session.CompanyID
&& tc.OrderNum == iOrderNum
select new { tc.Company, tc.OrderNum, tc.TermsCode }).FirstOrDefault();
if (OrderRow != null)
{
dr["TermsCode"] = OrderRow.TermsCode;
}
}
//this.PublishInfoMessage(sMsg, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}
// Finally fill our variable with the updated results
this.outDS = dsIn;
}
catch (Exception ex)
{
//The following stops this dead in it's tracks.
//throw new Ice.BLException(ex.Message);
//The following allows it continue but shows error message.
this.PublishInfoMessage(ex.Message, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}