Useful COM programming without class license ?

lee
Member Posts: 14
Good morning!
I'm writing a web service and matching client in VB .NET.
I need to update some Axapta tables from the web service. I don't want to directly access the SQL tables (fine for reading but recId becomes a problem when writing new records).
I'd really like to do it properly and interface with Axapta using COM. Which requires some useful Axapta-side classes to interface with the tables in question.
The problem is I don't have the class license for Axapta !
So I guess what I'd love to know is :
1. Is there some existing class in Axapta that allows me to write arbitrary data to an arbitrary table (while automatically populating recId) ?
2. Does recId have to be unique across all tables in Axapta? By this I mean is it illegal for a record in, say InventTable to have the same recId as a record in PurchTable?
Or must recId be unique only within a table? Could I write a straight SQL statement which locks the table, looks at the most recent recId and adds 1 to it?
3. Any other ideas as to how I can achieve my goal ?
Thanks in advance for any help. Before long I hope to have enough knowledge to actually help other people with Axapta queries!
Lee
I'm writing a web service and matching client in VB .NET.
I need to update some Axapta tables from the web service. I don't want to directly access the SQL tables (fine for reading but recId becomes a problem when writing new records).
I'd really like to do it properly and interface with Axapta using COM. Which requires some useful Axapta-side classes to interface with the tables in question.
The problem is I don't have the class license for Axapta !
So I guess what I'd love to know is :
1. Is there some existing class in Axapta that allows me to write arbitrary data to an arbitrary table (while automatically populating recId) ?
2. Does recId have to be unique across all tables in Axapta? By this I mean is it illegal for a record in, say InventTable to have the same recId as a record in PurchTable?
Or must recId be unique only within a table? Could I write a straight SQL statement which locks the table, looks at the most recent recId and adds 1 to it?
3. Any other ideas as to how I can achieve my goal ?
Thanks in advance for any help. Before long I hope to have enough knowledge to actually help other people with Axapta queries!
Lee
0
Comments
-
OK I think I have come up with a valid solution. Via COM I'll call systemSequence.reserveValues(1) to reserve and get the next available recId (ie. so no other Axapta process uses that recId).
Then I'll do an old-fashioned SQL insert using that recId.
Could anyone comment on the validity of this plan ?0 -
The plan is good. but you have to understand well about what and where you have to insert. Meaning, that for an inserted record to be good and valid, you sometimes have to insert records into 2 or 3 tables, not just one.Vanya Kashperuk,
My blog - http://kashperuk.blogspot.com
MorphX IT in Russian - http://www.lulu.com/content/723888
Inside Dynamics AX 4.0 in Russian - http://www.ozon.ru/context/detail/id/37145820 -
Hi Lee,
If you are using Ax 3.0 pre SP5 and are trying to insert records into virtual company, please read ahead.
A while ago I remember reading about a bug in Ax 3.0 (prior to SP5) involving reserveValues method.
Apparently if you are trying to insert records into Ax virtual company table, recIDs were drawn not from the virtual company table but from the current company account.
I believe this was fixed in SP5.
Regards,Harish Mohanbabu
Long way to go before I sleep..0 -
Thanks for the tip Harish. We seem to be only using SP1 !!
If anyone else if trying to do the same thing, I got this code from Onno on MS's Dynamics forum. It lets you insert arbitrary code into an arbitrary table via COm and takes care of RecId automagically:Dim Axapta As Object Dim MyRecord As Object Set Axapta = CreateObject("AxaptaCOMConnector.Axapta") Axapta.Logon ‘ create an Axapta record Set MyRecord = Axapta.CreateRecord("MyTable") ‘ set fields of record MyRecord.InitValue MyRecord.Field("Name") = "MyName" MyRecord.Field("Address") = "MyAddress" ‘ insert the record MyRecord.Insert
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