web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Open a local file with X++

(1) ShareShare
ReportReport
Posted on by 501
Hello, I want to open a local file in my C:\ drive when clicking a button in D365FO.
 
I'm in tier-1 environment
 
I tried to use browser.navigate function to open in a browser but it didn't work, it was giving pop up errors.
 
Even I tried to access the file directly to open it, and also it didn't work.
 
Seems like the D365FO can't read my local C:\ drive.
 
Can someone help.
 
 
I have the same question (0)
  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at
    What is business scenario you're dealing with? Your description isn't clear, e.g. opening a file in a browser is a very different thing than "reading a local drive by D365FO".
     
    If you want to work with the file in X++, note that X++ code running on a web server (usually in an Azure data center) can't connect to users' machines and manipulate files there. What you can do it uploading a local file to the web application (e.g. with File::getFileFromUser()) and process this uploaded copy rather than the local file. An alternative would be using a storage that the web application can access, e.g. having an Azure file share mapped as a local drive and write code to access the share from X++.
     
    Or do you want just an HTML hyperlink trying to open a local file (without the file ever reaching F&O)?
  • CU09091357-0 Profile Picture
    501 on at
    Martin Dráb thank you for your reply.
     
    My goal is to open some pdf files located in my C:\ drive.
     
    I don't mind if I just do my own link as C:\Attachments\file.pdf and write it in new tab. But I want it to be automated by x++ when clicking the button.
     
    The browser() function didn't work nor the system.io library
  • Verified answer
    Mohamed Amine Mahmoudi Profile Picture
    26,443 Super User 2025 Season 2 on at
     
    As far as i know, you can't access files on a local machine since D365fo is a web application. in this case, so i suggest you use power automate to retrieve your files through a connector (on-premises data getway).
     
    Best regards,
    Mohamed Amine MAHMOUDI
  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at
    Please give us more details than just repeating that you want to open a file.
     
    Do you mean that you assume that every user's computer has C:\Attachments\file.pdf (which sounds like a strange assumption to me) and you want to open the file by the web browser or a default application for PDF files? If so, we should ignore the remark "the D365FO can't read my local C:\ drive", because the requirement is not about reading any files in F&O, right?
  • CU09091357-0 Profile Picture
    501 on at
    Mohamed Amine Mahmoudi okay man, thanks for your clarification!
  • CU09091357-0 Profile Picture
    501 on at
    Martin Dráb I'm in my local environment, I'm using it as data archive.
    The attachments are not accessible because we don't have their metadata in the local emulator (127.0.0.1:10000), and we tried everything but nothing is working.
    I have all the attachments downloaded in my C:\ drive.
    I'm using the approach of opening a new tab with url: C:\attachments\filename (which is the fileid that I will take from the docuvalue table when I click the button that I created and wants to write the code that opens me a new tab inside), so the file open.
  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at
    First of all, your URL is wrong. You can't use the local path (C:\Attachments\file.pdf) as a URL; you must use the file URI scheme instead (e.g. file:///c:/Attachments/file.pdf). Please test the URL before continuing.
     
    But as I remember, such URLs don't work in Browser.navigate(). You'll need to look for a different solution. What about storing the files directly in the database (and avoid both this topic about local files and your problems with the Azure storage emulator)?
  • CU09091357-0 Profile Picture
    501 on at
    Martin Dráb will try this approach, thank you!
  • Verified answer
    Anthony Blake Profile Picture
    2,963 Super User 2025 Season 2 on at
     
    Are you fixing the file name and location, because if its interactive anyway (click of a button) you could use the file upload control or the file upload dialog File::GetFileFromUser()
     
     
    Thanks
    Anthony
  • CU09091357-0 Profile Picture
    501 on at
    @CU09091357-0 okay thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 456 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans