Experts,
I have a small app that writes to CI_Item. It has been working with no issues in Sage 100 v2017 Premium for my client in a Sage Server / Terminal Server setting. Now they are on v2020 Premium in the same setup (new servers), but we are running into issues on the Terminal Server (it works fine when I run the app on the Sage server).
Here is what is going on:
The app logs into the Sage company that needs to be updated, and that works. It is supposed to update a few Standard fields and UDFs in CI_Item (all of these fields can be modified in the UI by the user without any issues). The program is written to loop through the items and update one at a time.
Now when I run this from the TS, then the nWrite throws the following exception on the first line:
"Object Reference not set to an instance of an object."
The other items in the loop throw the following error on nWrite:
"Exception has been thrown by the target of an invocation."
I can see, that the values for the first line get actually updated.
The program is written in a way that you can hit a retry button to trigger the import for items that failed. Now when you click this button, the first item change will NOT throw an exception, but the others will. You can trigger the retry, and the first one will always make it.
That doesn't make sense, does it? Especially since this works properly from the Sage server. I can also see that the time it takes to build the connection into Sage/run the update is a few seconds. Not sure if there might be a connection issue. It worked fine in v2017 in the same virtual server environment.
Here is the section of the codes that fails. It's not getting to the retVal part where I would manually throw the exception.
retVal = (int)oItem.InvokeMethod("nWrite"); sLastFunction = "nWrite"; if (retVal == 0) { sErrorMsg = Regex.Replace(oItem.InvokeMethod("sLastErrorMsg").ToString(), "'", ""); throw new System.Exception("Error obj.Write."); } else if (retVal == 1) { nSuccess++; row.SetField("Status", "Updated"); row.SetField("UDF_SP_CHANGEDATE", DateTime.Now); row.SetField("UDF_SP_CHANGEUSER", _sCurrentSageUser); } retVal = (int)oItem.InvokeMethod("nClear");
Any ideas are appreciated!
Best,
B.