SBX - Search With Button

SBX - Forum Post Title

Filter data before XMLPort.Export()

Dynamics 365 Business Central Forum

Mohsin Abbas asked a question on 14 Jun 2019 6:11 AM
My Badges

Question Status

Suggested Answer

Hi 
I want to export XMLPort's data into a text variable after applying some filters. Currently I have this:

procedure GetJobTasksList(): Text
var
JobTask : Record "Job Task"; tempBlob: record TempBlob; IStream: InStream; Ostream: OutStream; StreamText: text;
JTXmlport: Xmlport 50000; begin TempBlob.Blob.CreateOutStream(Ostream);
//JobTask.Setfilter(/*filters*/)
//JTXmlPort.SetTableView(JobTask) Xmlport.Export(50000, Ostream); tempblob.blob.CreateInStream(IStream); tempblob.CalcFields(blob); StreamText := Base64Convert.StreamToBase64String(IStream); exit(StreamText); end;
If I use SetTableView on XMLPort variable (JTXmlPort) and then Use the Xmlport.Export() function it doesn't work and that makes sense. I need to be able to find a way so that I can export the data to a text variable but it should be filtered.
Reply
Mohsin Abbas responded on 18 Jun 2019 5:12 AM
My Badges
Suggested Answer

After a bit of searching I got to know that I was ignoring an optional parameter of the xmlport.Export() function. After applying filters on JobTask record, it can be sent as a parameter like this:

JobTask.Setfilter(/*filters*/)

JobTask.Findset;

Xmlport.Export(50000, Ostream,JobTask);

Reply
Mohsin Abbas responded on 18 Jun 2019 5:12 AM
My Badges
Suggested Answer

After a bit of searching I got to know that I was ignoring an optional parameter of the xmlport.Export() function. After applying filters on JobTask record, it can be sent as a parameter like this:

JobTask.Setfilter(/*filters*/)

JobTask.Findset;

Xmlport.Export(50000, Ostream,JobTask);

Reply

SBX - Two Col Forum

SBX - Migrated JS