SBX - Search With Button

SBX - Forum Post Title

XML port and file output

Dynamics 365 Business Central Forum

Armela Kamenica asked a question on 23 Oct 2018 12:06 PM
My Badges

Question Status

Suggested Answer

Hello there.
I have created an export xmlport with AL for BC 365.
I have defaulted the file name, smth like PO.csv.
It works great as far as exporting data, however after it is done generating the file, I want to get this file that downloads in the Downloads folder, and place it in a directory on the server connected to my local workstation.
I tried to use the download method but that did not work.

smth like this

DOWNLOAD(FromFile, DialogTitle, ToFolder, ToFilter, ToFile)

Someone suggested codeunit 419, but I can't figure out which function to use.

I want the xml port to run via the job queue, so the creating of the file and moving it on the server should happen without any user input or interaction. Any ideas ?

Reply
Suggested Answer

Answered here:

Reply
Armela Kamenica responded on 24 Oct 2018 9:54 AM
My Badges

Stefano

Yes, I figured out most of the code after I posted this, and I wrote in the other thread. I did not know how to delete this one. I still have a problem that I need help with. The file still gets saved my download folder. although I am specifying a path for it to go.

Is there a solution to that ?

Feel free to delete this one and answer on the the other thread.

Thanks

Reply
Suggested Answer

Are you working on the SaaS platform (cloud)? If so, you cannot specify a network folder because the cloud doesn't know that.

Reply
Armela Kamenica responded on 24 Oct 2018 10:41 AM
My Badges

I am working with BC365 on the cloud.

Reply
Suggested Answer

In the cloud, you cannot automatically save a file in a local folder. This is not supported (unless you set the compiler target to 'internal' for on-prem extensions).

What you can do is using a cloud storage provider and having a "shared folder" with an URL (for example, Onedrive).

Reply
Armela Kamenica responded on 24 Oct 2018 10:51 AM
My Badges

Good suggestion.

I can one a OneDrive for this.

Any idea how to do that ? Is there specific code that is needed for One Drive access ?

I appreciate your help.

Thanks

Reply
Suggested Answer

Nothing special to do, just create a folder and share it with your Office 365 (BC) users.

Reply
Armela Kamenica responded on 24 Oct 2018 10:59 AM
My Badges

SO in the code below

I have the following

TempBlob.Blob.CREATEOUTSTREAM(outvar);

xmlport.Export(50101,outvar);

TempBlob.Blob.CREATEINSTREAM(ReportInStream);

mypath := 'Send_PO.csv';

DOWNLOADFROMSTREAM(reportinstream, '', '\\Navision\cust\XXX\CSV\outbox\', '', mypath);

Do I change the path on the DOWNLOAFROMSTREAM pointing to the OneDrive share ??  It seems that the folder is not supported in DOWNLOADFROMSTREAM so I wanted to make sure I am using the correct line of code

Reply
Suggested Answer

Yes you can try this way if it works, but I'm not sure. I've to test :)

You can also try to exchange the files using Streams, TempBlob table and the BLOB fields in table 1220 Data Exch.

Reply
Armela Kamenica responded on 24 Oct 2018 8:31 PM
My Badges

Thank you for your reply, but I really do not know how to use table 1220.

Is there any code out there that I can see and review ?

I ideally need to be able to put files via an xml or codeunit in a folder on the server or a shared One drive.

I did some research and I did not find any documentation on it.

Any info from anyone in this group would be very beneficial.

Thanks

Reply
Suggested Answer

Answered here:

Reply
Suggested Answer

Are you working on the SaaS platform (cloud)? If so, you cannot specify a network folder because the cloud doesn't know that.

Reply
Suggested Answer

In the cloud, you cannot automatically save a file in a local folder. This is not supported (unless you set the compiler target to 'internal' for on-prem extensions).

What you can do is using a cloud storage provider and having a "shared folder" with an URL (for example, Onedrive).

Reply
Suggested Answer

Nothing special to do, just create a folder and share it with your Office 365 (BC) users.

Reply
Suggested Answer

Yes you can try this way if it works, but I'm not sure. I've to test :)

You can also try to exchange the files using Streams, TempBlob table and the BLOB fields in table 1220 Data Exch.

Reply

SBX - Two Col Forum

SBX - Migrated JS