Adding an order by XMLPORT, CODEUNIT
nara
Member Posts: 37
Hi,
I am not that experienced in Navision so I need some advise from you EXPERTS.
I have th following task:
I have to develope a .NET application that can retrieve Items, Contacts from NAvision and deliver Sales order to Navision, I did managed the first part but I have problem with delivering sales orders.
I have the following XML( just a example but the format is right )
<SalesOrder>
- <SalesHeader>
<OrderDate>14-02-08</OrderDate>
- <BillTo>
<CustomerNo>43687129</CustomerNo>
<Name>nasser tester</Name>
<City>Bergen</City>
<PostCode>5232</PostCode>
</BillTo>
- <ShipTo>
<Name>nasser tester</Name>
<Address>Kloppedalsveien 5</Address>
<City>Bergen</City>
<PostCode>5232</PostCode>
</ShipTo>
</SalesHeader>
- <SalesLines>
- <Line>
<ItemID>1900</ItemID>
<Description>Ramme</Description>
<UnitPrice>50</UnitPrice>
<Quantity>2</Quantity>
</Line>
</SalesLines>
</SalesOrder>
I did made a XMLPORT the maches this XML-hierachy which will try to insert data into SalesHeader and SalesLine tables, I did compiled my XMLPORT, no problem.
I did create a code unit to test this XMLPORT:
iFile.OPEN('c:\XMLTest\NEttsalg\SaleOrderTest.xml');
iFile.CREATEINSTREAM(iStream);
XMLPORT.IMPORT(50002,iStream);
iFile.CLOSE;
But when I try to run this CODEUNIT so I get the following error message alert
the following C/AL functions can be used only to a limited degree during write transactions
(because one or more tables will be locked)
Form.RunModal() is not allowed in write transactions.
CodeUnit.Run() is allowed in write transactions only if the return value is not used. For example, 'OK :=CodeUnit.RUn()' is not allowed.
Report.RunModal() is allowed in write transactions only if 'RequestForm = FALSE'.
For example,'Report.RunModal(...,FALSE)' is allowed.
DataPort.RunModal() is allowed in write transactions only if 'RequestForm = FALSE'.
For example, 'DataPort.RunModal(...,FALSE)' is allowed.
Use the COMMIT function to save the changes before this call, or structure the code differently.
Any Idea about what I do wrong!?
best regards nara
I am not that experienced in Navision so I need some advise from you EXPERTS.
I have th following task:
I have to develope a .NET application that can retrieve Items, Contacts from NAvision and deliver Sales order to Navision, I did managed the first part but I have problem with delivering sales orders.
I have the following XML( just a example but the format is right )
<SalesOrder>
- <SalesHeader>
<OrderDate>14-02-08</OrderDate>
- <BillTo>
<CustomerNo>43687129</CustomerNo>
<Name>nasser tester</Name>
<City>Bergen</City>
<PostCode>5232</PostCode>
</BillTo>
- <ShipTo>
<Name>nasser tester</Name>
<Address>Kloppedalsveien 5</Address>
<City>Bergen</City>
<PostCode>5232</PostCode>
</ShipTo>
</SalesHeader>
- <SalesLines>
- <Line>
<ItemID>1900</ItemID>
<Description>Ramme</Description>
<UnitPrice>50</UnitPrice>
<Quantity>2</Quantity>
</Line>
</SalesLines>
</SalesOrder>
I did made a XMLPORT the maches this XML-hierachy which will try to insert data into SalesHeader and SalesLine tables, I did compiled my XMLPORT, no problem.
I did create a code unit to test this XMLPORT:
iFile.OPEN('c:\XMLTest\NEttsalg\SaleOrderTest.xml');
iFile.CREATEINSTREAM(iStream);
XMLPORT.IMPORT(50002,iStream);
iFile.CLOSE;
But when I try to run this CODEUNIT so I get the following error message alert
the following C/AL functions can be used only to a limited degree during write transactions
(because one or more tables will be locked)
Form.RunModal() is not allowed in write transactions.
CodeUnit.Run() is allowed in write transactions only if the return value is not used. For example, 'OK :=CodeUnit.RUn()' is not allowed.
Report.RunModal() is allowed in write transactions only if 'RequestForm = FALSE'.
For example,'Report.RunModal(...,FALSE)' is allowed.
DataPort.RunModal() is allowed in write transactions only if 'RequestForm = FALSE'.
For example, 'DataPort.RunModal(...,FALSE)' is allowed.
Use the COMMIT function to save the changes before this call, or structure the code differently.
Any Idea about what I do wrong!?
best regards nara
0
Comments
-
My guess is that one of the fields you are validating has form.runmodal on it.
Instead of writing your own XML port, have you considered using the standard CG Sales Header XMLPort?0 -
If you enable debugger, you will see where the error is raised. It will be som code opening form or running report with requestform. This cannot be done when writing transaction was already started.0
-
Thank you both for your advise.
I can't find the XMLPORT that you mentined!
I did turned on debugging, problem was in mismatch between postcode and City, but I do get this message( the original message is Norwegian ) but here is the translation
Standard text code 1900 dose'nt exists!
Any Idea?0 -
It seems that you are validating "No." field before you set the correct "Type" fild option (is empty now and NAV assume Standard text code in "No." field). Fill the Type field fist (by Item value etc.).0
-
I believe you are absolutely right, I did see the problem right after I did posted my problem. I did try to put a value fro column No_ from table Item.
Thanks again, I will try
. 0 -
I realy messed up now, I am confused.
Now I get this error message, translated to english:
There is no Foreign exchange quotation in filter.
Filter: ExchangeCode: EUR, StartDate: "..".
Her is my XML and I am trying to add some rows to Sales Header and Sales Line Tables
- <SalesOrder>
- <SalesHeader>
<DocType>1</DocType>
<OrderDate>18-02-08</OrderDate>
<SellTo>43687129</SellTo>
- <BillTo>
<CustomerNo>43687129</CustomerNo>
<Name>Designstudio Gmunden</Name>
<City>Gmunden</City>
<PostCode>AT-4810</PostCode>
</BillTo>
- <ShipTo>
<Name>Designstudio Gmunden</Name>
<Address>Seepromenade 1b</Address>
<City>Gmunden</City>
</ShipTo>
</SalesHeader>
- <SalesLines>
- <Line>
<Type>2</Type>
<ItemID>1924-W</ItemID>
<Description>CHAMONIX basisreol</Description>
<UnitPrice>1330</UnitPrice>
<Quantity>7</Quantity>
</Line>
</SalesLines>
</SalesOrder>
Last friday I did managed to make this XML to work but I did changed some thing in my XML and now nothing work!!!! :oops: :? ](*,) #-o0
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
- 322 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
