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 :
Microsoft Dynamics CRM (Archived)

FileUpload control in WebResource HTML - How to get local file path in JavaScript?

(0) ShareShare
ReportReport
Posted on by

Hello,

I  have created one ribbon button on "Account" Record form. On Click of that button, it executes below html webresource.

<html><head>
<script src="ajax.googleapis.com/.../jquery.min.js"></script>
<script type="text/javascript">
     $(document).ready(function () {
      $("#btnSubmit").click(function(){
var url = "https://<tenant>.crm8.dynamics.com/cs/dialog/rundialog.aspx?DialogId=%7b7DF4BAD3-8D06-4259-A5A1-C9E2058ECC99%7d&EntityName=account&ObjectId=%7bB2B1E14F-53AD-E611-8106-C4346BDC3C21%7d";
window.open(url, "_blank", "width=1000,height=1000");
});  
    });
function myFunction() {
    alert($('input[type=file]').val());
                return false;
}
</script>
<meta><meta><meta><meta><meta></head>
<body style="overflow-wrap: break-word;">
<form action="demo.asp">
<input name="fileUpload" id="fuFile" type="file">
<input value="Submit" id="btnSubmit" onclick="myFunction()" type="button">
<input value="Close" type="button">
</form>
</body></html>


4846.Capture1.JPG

On click of Submit button, I want to get local file path in Javascript function and call one Dialog process with input parameter as selected file path. I know that in some of the browsers it returns as fake path. How can I achieve this?

Is there any work around or any other control I can use to achieve this?

Please suggest.

Thank you.

*This post is locked for comments

I have the same question (0)
  • ScottDurow Profile Picture
    21 on at

    Could you describe the scenario that you are trying to implement?

    You can't use the file upload control in this way and you can't pass any parameters to rundialog.aspx

    You would have to instead set a record attribute and then pick that up in the dialog.

  • MittalPatel Profile Picture
    on at

    Thank you Scott.

    Here is my scenario -

    1. For example there is an opportunity record. And for that record user wants to upload some documents.

    2. There are two user interactions -

    1. Upload document by browsing local disk

    2. Select related entity records

    3. Now, in custom dialog activity - what I am trying to achieve is -

    1. Get local drive path of selected file

    2. Read that file

    3. Read related entity records which are selected in dialog page

    4. Set metadata properties of document from above related record details

    5. Save document on SharePoint location.

    It is like uploading documents on sharepoint location which is OOTB, but I want to set metadata properties of that document before it gets uploaded to SP.

    ------------------------------------------

    In your response you suggested - "You would have to instead set a record attribute and then pick that up in the dialog."

    Can you please explain me on that? I didn't understand how to create a record attribute for file upload functionality.

    Thank you.

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans