Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Answered

Xrm.Device.pickFile Not Opening File Manager on Mobile Devices - Need Assistance

(0) ShareShare
ReportReport
Posted on by 15

Hi everyone,

I'm encountering an issue where the `Xrm.Device.pickFile` method is not opening the file manager on mobile devices.

I’m trying to use `Xrm.Device.pickFile` to allow users to select a file from their mobile devices, but the file manager doesn’t open when the method is called, however it does work in the Browser.

code snippet

var main = {
    // pickfile (client API reference)
    callMethod: function (executionContext) {
        // Reading attribute value from the form
        var formContext = executionContext.getFormContext();
        var dailyUpdateId = formContext.data.entity.getId().replace("{", "").replace("}", "");
        var uploadFileAttr = formContext.getAttribute("stu_photouploadfield").getValue();
        var dailyUpdateName = formContext.getAttribute("stu_name").getValue(); // Assuming this is the field for daily update name

        // Validating form field conditions
        if (uploadFileAttr) {
            var pickFileOptions = {
                accept: ["*/*"], // Allow any file type
                allowMultipleFiles: true // Allow multiple file selection
            };

            // Invoking pickFile Client API
            Xrm.Device.pickFile(pickFileOptions).then(
                function (data) {
                    // Handle the selected files
                },
                function error(error) {
                    // handle errors
                }
            );
        }
    }
};
  • Verified answer
    PATO Profile Picture
    15 on at
    Re: Xrm.Device.pickFile Not Opening File Manager on Mobile Devices - Need Assistance

    Hello,

    We finally have a solution. I reached out to the Microsoft PowerApps team, and they provided a solution. The documentation specifies that the "accept" option can only be audio, video, or image. With that said, we can omit this parameter, and it worked. Here’s the updated code:

    Xrm.Device.pickFile({
    // Maximum size of the file to be picked in bytes (example: 5 MB)
    maximumAllowedFileSize: 5242880,

    // Allow picking multiple files
    allowMultipleFiles: true
    }).then((e) => console.log("success"), (e) => console.warn(e));

  • PATO Profile Picture
    15 on at
    Re: Xrm.Device.pickFile Not Opening File Manager on Mobile Devices - Need Assistance

    Thank you for your follow-up on this issue. I wanted to share my findings. The failure occurs only in the Mobile app, not in the client browser. After some investigation, I couldn't find a definitive solution. However, I experimented with other methods like `captureImage` and `captureVideo`, which both worked.

    To address the issue, I defined a variable as follows:

    var isMobile = Xrm.Utility.getGlobalContext().client.getClient() === "Mobile";

    Then, I set up my options object like this:

    var pickFileOptions = isMobile ? {} : {
    maximumAllowedFileSize: 5242880,
    accept: ["*/*"],
    allowMultipleFiles: true
    };

    This approach worked and allowed me to select only one file. My question now is whether there to predefine an object for the mobile app that I can pass.

  • cchannon Profile Picture
    4,702 Super User 2025 Season 1 on at
    Re: Xrm.Device.pickFile Not Opening File Manager on Mobile Devices - Need Assistance

    Interesting. The documentation says that method is supported for web and mobile clients.

     

    Are you in the mobile app or mobile browser when this error happens?

    Do you get a return in the error handler of your async function that might help shed some light on this?

  • PATO Profile Picture
    15 on at
    Re: Xrm.Device.pickFile Not Opening File Manager on Mobile Devices - Need Assistance

    Thank you very much for your input, however, this is not a custom control, it's purely js where the method is triggered on an on-change event, and the dialog is supported to popup. I have been able to get the captureimage method to work with no problems but no issue when the pickfile method would not.

  • cchannon Profile Picture
    4,702 Super User 2025 Season 1 on at
    Re: Xrm.Device.pickFile Not Opening File Manager on Mobile Devices - Need Assistance

    Sure - 

     

    In the ControlManifest.Input.Xml file, you will find the input manifest ready for you to customize your control. Right after the <resources/> node, you will find a commented out section for <feature-usage> which should look like this:

     

    <!-- UNCOMMENT TO ENABLE THE SPECIFIED API
     <feature-usage>
     <uses-feature name="Device.captureAudio" required="true" />
     <uses-feature name="Device.captureImage" required="true" />
     <uses-feature name="Device.captureVideo" required="true" />
     <uses-feature name="Device.getBarcodeValue" required="true" />
     <uses-feature name="Device.getCurrentPosition" required="true" />
     <uses-feature name="Device.pickFile" required="true" />
     <uses-feature name="Utility" required="true" />
     <uses-feature name="WebAPI" required="true" />
     </feature-usage>
     -->

     

    To use any of those features, you need them to be uncommented in the manifest (this is a way of telling the app registration that you will be using capabilities that might require user permission or admin permission). In your case, all you need to do is swap out that commented block with something like this:

     

     <feature-usage>
     <uses-feature name="Device.pickFile" required="true" />
     </feature-usage>

     

    To learn more about the control manifest and its various uses, take a look at the documentation here.

  • PATO Profile Picture
    15 on at
    Re: Xrm.Device.pickFile Not Opening File Manager on Mobile Devices - Need Assistance

    I did not, do you happen to know how I would go about doing that or a resource that would be helpful? Thanks

  • cchannon Profile Picture
    4,702 Super User 2025 Season 1 on at
    Re: Xrm.Device.pickFile Not Opening File Manager on Mobile Devices - Need Assistance

    Did you remember to enable the PickFile feature in the App Manifest?

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 87 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 71 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 65 Super User 2025 Season 1

Overall leaderboard