mibuso.com

Microsoft Business Solutions online community
It is currently Fri Apr 25, 2014 4:16 am

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: How to Insert empty record in XMLPort
PostPosted: Mon May 14, 2012 12:10 pm 
Offline

Joined: Tue Mar 11, 2008 4:54 pm
Posts: 19
Location: Malaysia
Country: Malaysia (my)
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


Top
 Profile  
 
 Post subject: Re: How to Insert empty record in XMLPort
PostPosted: Tue May 15, 2012 6:07 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Mon Apr 04, 2005 3:49 pm
Posts: 218
Location: Sauðárkrókur
Country: Iceland (is)
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


Top
 Profile E-mail WWW  
 
 Post subject: Re: How to Insert empty record in XMLPort
PostPosted: Wed May 16, 2012 9:04 am 
Offline

Joined: Tue Mar 11, 2008 4:54 pm
Posts: 19
Location: Malaysia
Country: Malaysia (my)
Hi Gunnar,

Thanks for your reply.

Yea, it only exports the element if the Format is XML, but i need to export text instead :(.


Top
 Profile  
 
 Post subject: Re: How to Insert empty record in XMLPort
PostPosted: Wed May 16, 2012 11:03 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Mon Apr 04, 2005 3:49 pm
Posts: 218
Location: Sauðárkrókur
Country: Iceland (is)
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


Top
 Profile E-mail WWW  
 
 Post subject: Re: How to Insert empty record in XMLPort
PostPosted: Wed May 16, 2012 1:10 pm 
Offline

Joined: Tue Mar 11, 2008 4:54 pm
Posts: 19
Location: Malaysia
Country: Malaysia (my)
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 zzzzzz


Top
 Profile  
 
 Post subject: Re: How to Insert empty record in XMLPort
PostPosted: Wed May 16, 2012 1:17 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Mon Apr 04, 2005 3:49 pm
Posts: 218
Location: Sauðárkrókur
Country: Iceland (is)
By only using a Text[1024] string in the xmlport and code similar to this

Code: Select all
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


Top
 Profile E-mail WWW  
 
 Post subject: Re: How to Insert empty record in XMLPort
PostPosted: Thu May 17, 2012 6:22 am 
Offline

Joined: Tue Mar 11, 2008 4:54 pm
Posts: 19
Location: Malaysia
Country: Malaysia (my)
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?


Top
 Profile  
 
 Post subject: Re: How to Insert empty record in XMLPort
PostPosted: Thu May 17, 2012 3:35 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Mon Apr 04, 2005 3:49 pm
Posts: 218
Location: Sauðárkrókur
Country: Iceland (is)
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


Top
 Profile E-mail WWW  
 
 Post subject: Re: How to Insert empty record in XMLPort
PostPosted: Fri May 18, 2012 5:00 am 
Offline

Joined: Tue Mar 11, 2008 4:54 pm
Posts: 19
Location: Malaysia
Country: Malaysia (my)
Thanks for your feedback. That's no point of using XMLport then if that's the case.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: