I have a function that is utilizing a custom code widget to update a DB table. I am moving data from a system field to a new UD field because they needed a larger field. (I know I could do this with Business Objects, but in this case, I am potentially updating some older records which sometimes prevents this update.)
int counter = 0;
foreach (var dr in Db.OrderDtl.Where(x => x.Reference != x.Reference_c && x.Reference_c==string.Empty))
{
counter++;
dr.Reference_c = dr.Reference;
if (counter>1000)
break;
}
Here is where the oddities are occurring…
This works perfectly fine if it is ran as part of a BPM.
However, if you schedule this function to run, it will not update the table.
Does anyone know why or have a fix so this can be ran as a scheduled function?
using(var txScope = Ice.IceContext.CreateDefaultTransactionScope())
{
int counter = 0;
foreach (var dr in Db.OrderDtl.Where(x => x.Reference != x.Reference_c && x.Reference_c==string.Empty))
{
counter++;
dr.Reference_c = dr.Reference;
if (counter>1000)
break;
}
txScope.Complete();
}
The Db.Validate() is not here because there is no accessible extension method in the ILibraryContext.
I even had another thought since it will work as part of a BPM. I put the function execution on the Post Processing of Tip.GetNewTip. This works and updates the OrderDtl records as expected when you call the Tip.GetNewTip from the GUI. So I thought why not create a function that calls the Tip.GetNewTip and try to run it as a scheduled function. In this case, it doesn’t update the OrderDtl records as expected.