Hello! In the process of transitioning to Kinetic from E9. In AP Invoice Entry, we have a few UD fields that get updated on either the ChangeRefPONum or PreUpdate methods. Have some code that sums up the amount of money invoiced to date for a specific PO, but when I try and assign it to the respective UD field, I get this error:
“The left-hand side of an assignment must be a variable, property, or indexer”
where amtSum is the iterated variable. If I switch the two values, the code compiles, so I didn’t think it would be a syntax issue, but maybe it is??? Have been able to perform calculations in other methods with the UD Field in that form, but have yet to set a variable to one.
If anyone has any advice on this issue, I would greatly appreciate it!
Unfortunately, I tried the first option and it couldn’t find the variable. The 2nd option threw an error saying “Method name expected”. I added in a “.” after ds.APInvHed[0] to see if that would help (really just a shot in the dark) and got an error saying “Identifier expected”. Is there a method that calls on UD fields?
Ok haha, I was looking at the first bit of code you sent and was like “oh, I’m in way over my head”. This looks much more familiar, but unfortunately, it’s still saying that APInvHedRow doesn’t contain a definition for “Number03”.
This freed me from the syntax error, but I got one of those wonky error messages when I tried to test it (that usually comes from something wrong with my foreach loop). Gonna run some null tests on it to see if that’s what is causing the issue.
I had something in post processing ChangeRefPONum already that had come thru the ABL conversions from 9 that I slammed your code into and added a piece I use to sum previous quantities, but has sql do the work.
This runs, but I don’t have Number03
/* sum amount */
foreach (var tt in ds.APInvHed)
{
using (System.Transactions.TransactionScope txScope = IceDataContext.CreateDefaultTransactionScope())//start the transaction
{
double amtSum = Db.APInvHed.Where(i=> i.Company == CompanyID && tt.REFPONum == i.REFPONum).Sum(x=> (double?) x.DocInvoiceVendorAmt) ?? 0; //has to be double because sql returns that if null
Ice.Diagnostics.Log.WriteEntry($" amtSum is {amtSum} ");
//tt.SetUDField<decimal>("Number03", (decimal)amtSum);
txScope.Complete();//commit the transaction
}
}
So I ran a bunch of null tests and found that the foreach was good. It was when I took out the statement assigning amtSum to Number03 that the error went away so it seems like I still need to fix that part. Not sure how it compiled if it was just going to throw an error when the method gets called…
Will have to dig into that part more, but I appreciate all of the help so far!
The database context will include the _UD table in the ds.APInvHed object. Have you run a debugger on the code to see what the ds.APInvHed object looks like?
I’m sure there’s a better way to debug, but I set callContextBpmData.Character05 = ds.APInvHed.ToString();
and threw it on a show message widget and got this:
I think it’s tt.SetUDField<decimal>("Number03", amtSum); that is causing it because when I comment that out, it runs fine. It just seems like every time I try and fill that UD field, things go wrong.
Although, I am curious about this event viewer you speak of. Where would I find that? (I apologize for my inexperience)