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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Xrm.Device.pickFile No...
Power Apps
Unanswered

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
                }
            );
        }
    }
};
I have the same question (0)
  • cchannon Profile Picture
    4,702 Moderator on at

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

  • PATO Profile Picture
    15 on at

    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 Moderator on at

    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

    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 Moderator on at

    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

    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.

  • Verified answer
    PATO Profile Picture
    15 on at

    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));

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard