We are using UD100 table for records from the Resource Table which come from Resource Groups which hold tooling records. UD100A is then used to store maintenance records against the tool. We did set this up against the Resource table but updating records with more than 100 records in a Resource Group was really slow. Anyway, in order to keep the UD100 data up-to-date I am trying to create a BPM that will update UD100 if certain fields are changed (such as the Resource Group description). I have the following code, which I have working for similar BPM’s but cannot figure out the error:
Can you post the code from the working example?
At first look, the UD100_iterator is a variable that you have not defined. At least that’s what the error is saying.
A stray semicolon after the “foreach” brackets?
Thank you… I’ve been going cross eyed looking at it!
UD100 = UD100_iterator;
This is not allowed.
All you have to do is UD100_iterator.ResGrpDescC = ttResourceGroup_xRow.Description.
You might think about doing a couple of changes to the code…
-
put a transaction scope / DB.Validate / TxScope.Complete around your update
-
put a.With(LockHint.UpdLock) into your query to make sure that you have the record locked.
-
simplify everything…you dont need to put things into a Var, and then assign the var to another var to update it.The smaller
foreach loop does the trick -
Note, I also made smallar var names to make the code smaller too(ie…resGrp instead of ttResourceGroup_Row)…
This is untested, so there might be typos:
var resGrp = ttResourceGroup.FirstOrDefault();
if (resGrp = != null) {
using(var txScope = IceContext.CreateDefaultTransactionScope()) {
foreach (var ud100 in Db.UD100.With(LockHint.UpdLock).Where(x =>
x.Company == resGrp.Company &&
x.ResGrpDesc_c == resGrp.ResourceGrpID)) {
ud100.ResGrpDesc_c = resGrp.Description;
}
Db.Validate();
txScope.Complete();
}
}
Thank you. I’ll look at updating the code.
Thank you, I’ll work through your suggestions