We added a UD column to the OrderHed and OrderRel tables called IsBackOrdered_c (bool). Whenever the column in OrderHed changes (either on save or right away), we want a popup displayed asking the user if they also want to update the Back Ordered status to all the releases.
What is the best approach for updating the releases?
Method Directive on MasterUpdate, App Studio, or combination of App Studio and Function?
I tried configuring it in App Studio but apparently wasn’t setting something up correctly because I wasn’t able to retrieve all the releases and update them.
I have it working in a Method Directive on MasterUpdate. The Pre-Processing checks if this column changed, if so, I then call a BPM Data Form to ask if they want all the releases updated. If yes, then Enable Post Directive and execute this c# code:
using (var txScope = IceContext.CreateDefaultTransactionScope())
{
// Get the OrderHed record from the dataset
var orderHed = (from hd in ds.OrderHed
select hd).FirstOrDefault();
if (orderHed != null)
{
bool isBackOrdered = false;
// Get the IsBackOrdered_c value from OrderHed
var udFieldValue = orderHed["IsBackOrdered_c"];
if (udFieldValue != null)
{
isBackOrdered = Convert.ToBoolean(udFieldValue);
}
// Query ALL OrderRel records from the database for this order
var allOrderRels = (from rel in Db.OrderRel
where rel.Company == orderHed.Company
&& rel.OrderNum == orderHed.OrderNum
&& rel.OpenOrder == true
&& rel.VoidRelease != true
&& rel.IsBackOrdered_c != isBackOrdered
select rel);
// Update each release
foreach (var rel in allOrderRels)
{
rel["IsBackOrdered_c"] = isBackOrdered;
Db.Validate();
}
}
txScope.Complete();
}
Then run the Invoke BO Method on GetByID.
Is this a good approach?
Or would it be better to Invoke a Function to make the changes to all the releases instead of doing it inside the Execute c#.
Or from App Studio?