[Dynamics Nav 2015]
Hello everyone,
I need to call an xmlport (output only) to create a dataset I can send to an external reporting source.
I have two problems on this one from different approches.
1- If I call xmlport.Export from a codeunit so the save dialog is not shown, the page with the required filter fields is not show (need to show this page)
2- If I call the xml directly, the filters are shown but also the save dialog
So basically need to be able to output a structured XML file filtered on the user selection and WHITOUT a save dialog. Using a process only report is not good as the export format is not really readable from our reporting tool (every level is dataitem).
Does some have done something similar? any hint on how to achieve that?
Patrick Venner
programmeur-analyste
Cabico Custom Cabinetry0
Answers
You need to create a Page/report where you can enter the parameter and call the XMLPort with that parameter..
Please verify my answer if it helps you.
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.
it almost worked!
I've try a solution like this (found on another forum)
It works for simple xmlport but let says my xmlPort contains Sales Header with a link on Sales Line.
I did the same relation on the calling report. I've set filter on Sales Header AND Sales line. The filter I've applied in sales Line."Line No." is not consider as I can only send Sales header as parameter to export.
Any other clues?
programmeur-analyste
Cabico Custom Cabinetry
programmeur-analyste
Cabico Custom Cabinetry
Would you please share your solution with the rest of the community.
First I must tell that @zohaibu95 send me on a good path. But just not enough to be a full solution.
After thinking about it, I should have come to this solution way faster than I did.
Here what I’ve done:
First create your XMLPort with all the records you need in with all the correct relations. That is what will be exposed as XML (or any other format you choose).
Then, in the XMLPort, create a public function call SetRecFilter. This function should have all the same records as you xmlport (thos who need filters) set as “VAR” (or ByRef for .NET users) parameters
In this function use regular code to COPYFILTERS from all parameters records to the corresponding XMLPort record.
That was the hardest part of it!
Now, create a report with all the same records that you passed as parameters in SetRecFilter. No need to bother for the relation but it will reduce the time the report will run. Adjust the property so the report is ProcessingOnly. Make sure that UseRequestPage is set to “yes”.
On the OnPost Report trigger add your code to call your XMLPort as a variable. Not the XMLPORT.EXPORT([xmlportID],[output],[record]) thing!
Don’t forget to call the SetRecFilter function passing the reports records as parameters prior to call the export of you XMLPort variable.
And your pretty much done!
But beware, in my solution, we had to manipulate the xml little more so we could group by child Item prior to the Top Level record. but that is an other story.
programmeur-analyste
Cabico Custom Cabinetry