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)

How to upload multiple notes using html button javascript/jquery ?

(0) ShareShare
ReportReport
Posted on by

Below is clearly html and php,but I want to make custom ribbon workbench html button that can upload multiple notes for one entity.How do i start?do I need to use xrm,jquery or anything?

<html><head>
<meta charset="UTF-8">
<title>Document</title>
<meta><meta></head>
<body style="word-wrap: break-word;">
<form action="upload.php" method="post" multipart="" enctype="multipart/form-data">
<input type="file" name="img[]" multiple="">
<input type="submit">
</form>

</body></html>

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Adrian Begovich Profile Picture
    1,027 Moderator on at

    Hi Belcaliz Almanzar,

    You might find this article on uploading notes (annotations) using JavaScript and REST useful.

  • Community Member Profile Picture
    on at

    Can you enlighten me please how to use the coding?I need to put HTML and the complete code in the same web resource text editor?

  • Community Member Profile Picture
    on at

    Is it something like this?

    <html>

    <head>

    <title>Notes</title>

    <p>Add Notes</p>

    <input type="text" id="titleid" placeholder="Title:" style="margin-left:10px; margin-bottom:10px; width:60%"/>

    <div >

    <textarea name="textarea" placeholder="Description" style="margin-left:10px; margin-bottom:10px; width:60%" cols="40" rows="5" id="descriptid"></textarea>

    <div class="header">

          <div class="contactheader">

      <div align="left" style="margin-left:0px;margin-bottom:0px;margin-top:15px ">  <label style=" font-size:14px;">Select Files to Upload</label></div>

        <input type="file" id="file" name="files[]" multiple="true" value="" style="float:left;margin-left:0px;margin-top:0px; width: 380px" />            

    <button class="button" onclick="save()">Save</button>

    </script>

     <script type="text/javascript" language="javascript" >

    var id = opener.parent.Xrm.Page.data.entity.getId();

    var nam = opener.parent.Xrm.Page.data.entity.getEntityName();

    function _arrayBufferToBase64(buffer) {

    var binary = '';

    var bytes = new Uint8Array(buffer);

    var len = bytes.byteLength;

    for (var i = 0; i < len; i++) {

    binary += String.fromCharCode(bytes[i]);

    }

    return window.btoa(binary);

    }

    function createNote(title, description, docBody, fName, mType) {

    var entity = {};

    if (docBody != null & fName != null & mType != null) {

    entity.DocumentBody = docBody;

    entity.FileName = fName;

    entity.MimeType = mType;

    }

    entity.Subject = title;

    entity.NoteText = description;

    entity.ObjectId = {

    Id: id,

    LogicalName: nam

    };

    SDK.REST.createRecord(

    entity,

    "Annotation",

    function (result) {

    var newEntityId = result.AnnotationId;

    opener.RetrieveAnnotations(null);

    window.close();

    },

    function (error) {

    Xrm.Utility.alertDialog(error.message, null);

    }

    );

    }

    function save() {

    var file = document.getElementById("file").files[0];

    var subject = document.getElementById("titleid").value;

    var desc = document.getElementById("descriptid").value;

    if (file) {

    var reader = new FileReader();

    reader.onload = function (evt) {

    var str = _arrayBufferToBase64(reader.result);

    createNote(subject, desc, str, file.name, file.type);

    }

    reader.readAsArrayBuffer(file);

    }

    else {

    createNote(subject, desc, null, null, null);

    }

    }

    </script>

    </body>

    </html>

  • Community Member Profile Picture
    on at

    Below is the HTML file that i am using to upload the multiple files:

    <input id="browse" type="file" onchange="previewFiles()" multiple>
    <div id="preview"></div>

    <script>
    function previewFiles() {

    var preview = document.querySelector('#preview');
    var files = document.querySelector('input[type=file]').files;

    function readAndPreview(file) {

    // Make sure `file.name` matches our extensions criteria
    if ( /\.(jpe?g|png|gif)$/i.test(file.name) ) {
    var reader = new FileReader();

    reader.addEventListener("load", function () {
    var image = new Image();
    image.height = 100;
    image.title = file.name;
    image.src = this.result;
    preview.appendChild( image );
    }, false);
    reader.readAsDataURL(file);
    }
    }

    if (files) {
    [].forEach.call(files, readAndPreview);
    }
    }

    </script>

    I would like to create annotation record as i am trying to achieve this functionality from resco. Can somebody please enlighten on this?

  • Community Member Profile Picture
    on at

    Change [tag:document] for [tag:document]s, Then you have to loop all the documents and gather the files in an array.

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