I’m learning to use Functions for the first time and can’t quite get it to work. I have a BAQ that calculates the first Go Negative Date (mirrors the time phase). It’s huge and takes too long to run in a dashboard so I want to take the information and populate it into Part UD Fields (GoNegDate & GoNegUpdated).
My Function runs without errors but the Part Table isn’t being updated. I have function DB Access from Code set to Read/Write and the Updateable box checked on my Part table reference.
BAQ:
Invoke Ice.DynamicQuery.ExecuteByID then run custom code:
Code:
var resultsTable = baqResults.Tables["Results"];
foreach (System.Data.DataRow row in resultsTable.Rows)
{
var partNum = row["Part2_PartNum"].ToString().Trim(); // trim to prevent mismatch
var goNegDate = row["Calculated_GoNegMain"] as DateTime?;
var updatedDate = row["Calculated_UpdatedDate"] as DateTime?;
var part = Db.Part.FirstOrDefault(p => p.PartNum == partNum);
if (part != null)
{
part.GoNegDate_c = goNegDate;
part.GoNegUpdated_c = updatedDate;
updatedCount++;
lastPart = partNum;
}
}


