Automation variable has not been instantiated - IXMLDOMNode

krussellm
Member Posts: 11
Hello,
I have the following variable setup in the global variables:
xmlNode : Automation 'Microsoft XML, v6.0'.IXMLDOMNode
I have a report that is run that executes code in a codeunit and it works perfectly.
Here is part of the code that is in question:
CLEAR(xmlNode);
xmlNode := xmlNodeList.item(i - 1);
The above code runs from the report executing the codeunit with no errors.
I am trying to run this exact same process in a new codeunit that executes the exact same codeunit as used the report does. I copied over all the code and variables to this new codeunit. This new codeunit does exactly the same thing as the report.
When I run the new codeunit, I get the following error:
"This Automation variable has not been instantiated"
When I run the debugger, the error occurs at this line:
xmlNode := xmlNodeList.item(i - 1);
If I try to do a CREATE on xmlNode (which I read you can't do) I get the error "Cannot create an instance of the OLE or automation server", blah blah blah. I understand that this automation cannot be initialized this way.
My question is how do I make this work when executing from a codeunit and not a report? I have checked the code over and over again and have verified that the codeunit matches with the report.
I am using Dynamics NAV 2009 R2 client with the same version for the database.
Any help would be greatly appreciated.
Thank you,
Kris
I have the following variable setup in the global variables:
xmlNode : Automation 'Microsoft XML, v6.0'.IXMLDOMNode
I have a report that is run that executes code in a codeunit and it works perfectly.
Here is part of the code that is in question:
CLEAR(xmlNode);
xmlNode := xmlNodeList.item(i - 1);
The above code runs from the report executing the codeunit with no errors.
I am trying to run this exact same process in a new codeunit that executes the exact same codeunit as used the report does. I copied over all the code and variables to this new codeunit. This new codeunit does exactly the same thing as the report.
When I run the new codeunit, I get the following error:
"This Automation variable has not been instantiated"
When I run the debugger, the error occurs at this line:
xmlNode := xmlNodeList.item(i - 1);
If I try to do a CREATE on xmlNode (which I read you can't do) I get the error "Cannot create an instance of the OLE or automation server", blah blah blah. I understand that this automation cannot be initialized this way.
My question is how do I make this work when executing from a codeunit and not a report? I have checked the code over and over again and have verified that the codeunit matches with the report.
I am using Dynamics NAV 2009 R2 client with the same version for the database.
Any help would be greatly appreciated.
Thank you,
Kris
0
Comments
-
At first glance, I would say that either the index (i-1) doesn't return a proper node, or your node list isn't instantiated properly. That could be the case if you f.i. create the node list in a codeunit but later on that codeunit goes out of scope and the instance of your node list will be terminated."Money is likewise the greatest chance and the greatest scourge of mankind."0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions