Exporting comments in XMLPort

bhalpin
Member Posts: 309
Hi.
I am trying to configure an XMLPort to export posted whse shipments (Transfer Shipment Header and and associated Transfer Shipment Lines).
The lines export as expected, but I am having trouble with the comments attached to the header. The format I want to obtain is:
In the report designer, I have:
The result I am getting is only the 1st comment line:
Can anyone point out where I'm going wrong? ](*,)
Thanks' in advance.
Bob
I am trying to configure an XMLPort to export posted whse shipments (Transfer Shipment Header and and associated Transfer Shipment Lines).
The lines export as expected, but I am having trouble with the comments attached to the header. The format I want to obtain is:
... <Comments> <Comment>Comment 1</Comment> <Comment>Comment 2</Comment> ... <Comment>Comment n</Comment> </Comments> ...
In the report designer, I have:
Shipment Element Table TransShipHeader(Transfer Shipment Header) ... Comments Element Table InventoryCommentLine(Inventory Comment Line) SourceTableView: WHERE(Document Type=CONST(Posted Transfer Shipment)) LinkTable: TransShipHeader LinkFields: No.=FIELD(No.) MinOccurs: Zero MaxOccurs: Once Comment Element Field InventoryCommentLine::Comment MinOccurs: Zero MaxOccurs: Unbounded
The result I am getting is only the 1st comment line:
<Comments> <Comment>Comment 1</Comment> </Comments>
Can anyone point out where I'm going wrong? ](*,)
Thanks' in advance.
Bob
0
Comments
-
Hi Bob, it seems to be your MaxOccurs propertybhalpin wrote:In the report designer, I have:
MaxOccurs: Once
0 -
Hi.
Thank's, but if I set the MaxOccurs on 'Comments' to Unbounded, I get this:<Comments> <Comment>Comment 1</Comment> </Comments> <Comments> <Comment>Comment 2</Comment> </Comments> <Comments> <Comment>Comment 3</Comment> </Comments>
?????
Bob0 -
DenSter wrote:Hi Bob, it seems to be your MaxOccurs property
The issue I believe is Navision doesn't allow multiple of the same elements when exporting, but it will do this fine when importing. I suppose it just does not know how to interpret it.
The only way I can see you being able to do this is to do the following:-
1) Remove the 'Comment' element within the 'Comments' node
2) Export the XMLport to a Stream to be manipulated using the MSXML Automation
-
a) Export to a Temporary Blob
b) Load via Stream to XML Dom Document
4) And finally exporting to file (which can be easily done using the automation; XMLDom.save('C:\Path\File.xml'))
If you would like some sample code let me know and I'll whip some up for you.
(You can download the latest version of MSXML at this link.)0 -
Hi Xypher.
Yikes!
Before posting this topic I searched the forum and saw this stuff mentioned.
Before jumping off that cliff thouhg, there's got to be an easier way to get the comments out. As it stands, the specs for the receiving end of this file are not defined yet - so I'm pretty free to set the output format as I like. Would you see anything wrong (XML-wise) with this:... <Comments> Comment Line 1 Comment Line 2 ... Comment Line n </Comments>
If that looks kosher, then I guess my next question is how to produce it.
Is this the right track:
- Change Comments to Element, Text
- In Comments - Export::OnBeforePassVariable()
- Define a local record variable for the comments table
- Set filters to get the ones I want
- Iterate through the records, appending the text to Comments
What do you think?
Bob0 -
You cannot dynamically manipulate elements in XMLports. Sorry0
-
Sorry Xypher,
too late - I tried it:
(Comments, Element, Text)Comments - Export::OnBeforePassVariable() Comments := ''; InvComments.SETFILTER("Document Type",'Posted Transfer Shipment'); InvComments.SETFILTER("No.",TransShipHeader."No."); IF InvComments.FINDSET THEN BEGIN REPEAT Comments := NewComments + InvComments.Comment; UNTIL InvComments.NEXT = 0; END;
In the output file, I get:<NewComments>Comment 1Comment 2Comment3</NewComments>
What do you think?
Bob0 -
You're not creating individual comment elements with that code. All I see is adjusting the output for NewComments element.
But if that will work for you then sure go for it.0 -
It works for me - as long as I get all the comments out the format is not critical.
Also, the code in my prior post was wrong. NewComments was the name I used for testing, and I didn't edit all the occurances to 'Comment' before posting. The code should read:Comments - Export::OnBeforePassVariable() Comments := ''; InvComments.SETFILTER("Document Type",'Posted Transfer Shipment'); InvComments.SETFILTER("No.",TransShipHeader."No."); IF InvComments.FINDSET THEN BEGIN REPEAT Comments := Comments + InvComments.Comment; UNTIL InvComments.NEXT = 0; END;
and the output:<Comments>Comment 1Comment 2Comment3</Comments>
Thank's for your help Xypher.
Bob0 -
With the code you provided, you may very easily run into 1024 buffer overflow with the Comments variable.
I would recommend switching from DataType: Text to BigText and do the following,Comments - Export::OnBeforePassVariable() //Don't need to initialize/clear the value if you don't assign a table/field to the element InvComments.SETRANGE("Document Type",'Posted Transfer Shipment'); InvComments.SETRANGE("No.",TransShipHeader."No."); IF InvComments.FINDSET THEN REPEAT Comments.ADDTEXT(InvComments.Comment); UNTIL InvComments.NEXT = 0;
0 -
Thank's (again!)
I had seen that coming, but hadn't gone after it yet.
Right now I'm wrestling with trying to add Lot No. information elements to each line item. What a swamp!
I've looked at the way the info is assembled:
Table 5745: Transfer Shipment Line.ShowItemTrackingLines(), calls:
Codeunit 6500: Item Tracking Management.CallPostedItemTrackingForm(DATABASE::"Transfer Shipment Line",0,"Document No.",'',0,"Line No.");
CallPostedItemTrackingForm creates a a temporary Item Ledger Entry table, and then calls Item Tracking Management.RetrieveILEFromShptRcpt(), passing it the table to be filled up with the Lot No lines.
Looks easy enough to use/steal/copy/whatever. But - I think there's a(nother) brick wall coming because I haven't found a way to use a temporary table as the data source for an XML port.
Do you think there's an easier way to find/export the lot no information?
Bob0 -
You can always declare the temporary table as a local variable (without needing to assign table/field properties to element(s)) construct the temporary table and loop through the records in whichever fashion you need whilst assigning the fields.
Other than that I don't really know what is involved with "Lot No. Information", I'm just a Jr. Programmer.0 -
bhalpin wrote:Hi.
Thank's, but if I set the MaxOccurs on 'Comments' to Unbounded, I get this:
I kind of lost track of this thread, but it should be possible to make this work.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