Hello SAP Community,
I'm facing an contented with the SAP Business One SDK portion trying to adhd a UserField to a table. The mistake seems related to the notation number of COM objects. Here’s the context:
I person a method that retrieves tract accusation from a root array utilizing a UserFieldsMD entity and past attempts to make a akin tract successful a destination table. I'm utilizing Recordset and UserFieldsMD objects to grip this process.
Here’s a high-level outline of my process:
- I initialize a UserFieldsMD entity and a Recordset to retrieve the tract information from the root table.
- I extract the indispensable tract information and store it successful a .NET dictionary.
- I merchandise the UserFieldsMD and Recordset COM objects to negociate resources effectively.
- I initialize a caller UserFieldsMD entity for the destination array and acceptable its properties based connected the extracted data.
When I effort to adhd this UserField to the destination table, I brushwood a refcount error.
I fishy that this contented is related to however COM objects are managed and released wrong the discourse of my method, particularly since determination appears to beryllium a regulation connected the fig of progressive COM objects.
Could idiosyncratic delight supply guidance connected champion practices for managing COM entity notation counts erstwhile adding UserField objects successful SAP Business One SDK? Are determination circumstantial patterns oregon techniques recommended to debar specified errors?
Here is the afloat codification I americium using. The mistake occurs astatine the CreateField method (line 255):
https://gist.github.com/jonathascosta/6ea59e966c46eb43a74992151f60ab85
Any insights oregon suggestions connected however to decently grip the lifecycle of these COM objects to debar refcount errors would beryllium greatly appreciated.
Thank you successful beforehand for your assistance!