Version 2024.1 On-Premise
I’ve got an app studio customization where there’s a button that calls a function, passing it two parameters (pPkgCode, pCustID). In the function, I do some editing to ensure it’s a valid Customer ID and does some additional edits on the packaging code. I have an output parameter that’s a message that the calling application displays.
When I call this function the first time, it successfully reads the Customer table. However, if I turn around and call this a second time with the same parameters, it does NOT find the customer row. I’ve stripped out the rest of the code, and it’s consistent. If I close my calling app and come back in, it’s the same thing, I read the customer table successfully the first time, fails on all subsequent reads.
My stripped down code is as follows:
var context = (Erp.ErpContext)Ice.Services.ContextFactory.CreateContext();
var erpContext = new Erp.Internal.Lib.CCredChk(context);
pOutMessage = string.Empty;
// this line verifies the values of the parameters
pOutMessage = "Parameters: " + pMode + "-" + pPkgCode + "-" + pCustID + "<<\n";
var cust = ( from crow in erpContext.Db.Customer
where crow.Company == Session.CompanyID
&& crow.CustID == pCustID
select new { crow.Name } ).FirstOrDefault();
if (cust == null ) pOutMessage += "Invalid Customer ID: " + pCustID + ".\n";
if ( pOutMessage != string.Empty )
{
erpContext.Dispose();
context.Dispose();
return;
}
So, the first time i run it, I just get the Parameters, so the “if cust == null” doesn’t execute as it found the customer ID. Click the button a second time with the same parameters, it does the same read, but this time the “if cust == null” executes.