How to Insert empty record in XMLPort
biant123
Member Posts: 29
Hi,
I have created a XMLport that can import and export records in text. The XMLport is being called from a report by .export or .import.
I have few different tables in the xmlport, but some of the tables might have empty record, so I need to insert empty line to the text file if the table is empty during Export (it does in dataport). Otherwise during Import, if the empty line does not exist, the XMLport will read the wrong record/text from the file.
Any idea how to insert the empty line to represent the record is empty? Like it does in dataport? :-k
I have created a XMLport that can import and export records in text. The XMLport is being called from a report by .export or .import.
I have few different tables in the xmlport, but some of the tables might have empty record, so I need to insert empty line to the text file if the table is empty during Export (it does in dataport). Otherwise during Import, if the empty line does not exist, the XMLport will read the wrong record/text from the file.
Any idea how to insert the empty line to represent the record is empty? Like it does in dataport? :-k
0
Comments
-
If you have MinOccurs = Once property on an Element you will always get the element exported.________________________________
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com0 -
Hi Gunnar,
Thanks for your reply.
Yea, it only exports the element if the Format is XML, but i need to export text instead
. 0 -
Then your solutions is to use temporary records and check for the need to install an empty record before you start the export.________________________________
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com0 -
Hi Gunnar,
I have already tried to use temp record and insert an empty record to the temp table before export, so the text result is:
1st record xxxxxx
2nd record yyyyy
,,0.00,,
4th record zzzzz
But is it possible to get a total empty line instead? For example:
1st record xxxxxx
2nd record yyyyy
4th record zzzzzz0 -
By only using a Text[1024] string in the xmlport and code similar to this
IF DecimalValue = 0 THEN TextValue = '' ELSE TextValue = <Formatted string from all record fields>;
________________________________
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com0 -
Hi Gunnar,
Hmm... I am not sure if we are thinking the same approach? I have make a simple XMLport (as shown below) to try on as my original xmlport has too many tables.
on my XMLport:
Node Name Node Type Source Type Data Source
Root Element Text <Root>
Customer Element Table <Customer>(Customer)
no Element Field Customer::No.
name Element Field Customer::Name
ReasonCode Element Table <Reason Code>(Reason Code)
code Element Field Reason Code::Code
description Element Field Reason Code::Description
amt Element Field Reason Code::Contract Gain/Loss Amount
I have set the table as Temporary.
On each table Export::OnPreXMLItem(), i insert an empty record to the temp table:
IF gReasonCode.ISEMPTY THEN BEGIN
"Reason Code".INIT;
"Reason Code".INSERT;
END;
and i call this xmlport from a report by using xmlport.export
So how do you write the empty line?0 -
You remove all elements with the type Field and insert one with the type text. Then create the text value from the record data________________________________
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com0 -
Thanks for your feedback. That's no point of using XMLport then if that's the case.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K 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
- 326 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