locked
CRM 2013: Javascript to read file content as byte array RRS feed

  • Question

  • I have a custom entity in the form of which I have an embedded websource (html\javascript). I am using the input "file" to browse a local file.

    Now I want to be able to read the content of the chosen file as byte array and store it - which later will be used by an external system ( written in C# code). FYI-  the file could be of any kind -txt,pic, pdf .....

    Could some one kindly tell me the simplest java script code to achieve at least the reading part.

    I think I will be able to take care of the storing part (I am planning store the bytes as "space" separated string in multiline text field)

    PLEASE DO NOT TELL ME TO USE NOTES AND ATTACHMENTS - as it's not going to serve my need. 


    Hasibur Rahman

    Wednesday, May 6, 2015 1:43 AM

All replies

  • Hi,

    What sort of file will you be reading on the user's computer and will you be allowed to do that?

    Regards


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Wednesday, May 6, 2015 8:43 AM
  • Rickard,

    I basically want to upload a file (in binary format) in the CRM system and then an external system (written in C#) would read that file and upload it in it's own system. The file could be text or picture or PDF or anything for that matter.

    What is the easiest way to achieve that?

    I am not quite sure what do u mean by if I will be allowed. This operation will be performed by agents using CRM . Is there a reason why they can upload attachments  as Notes but not this?

    Thanks


    Hasibur Rahman

    Wednesday, May 6, 2015 12:52 PM
  • Hi,

    i found some resources, about working files in JS:

    http://stackoverflow.com/questions/14446447/javascript-read-local-text-file

    http://blog.teamtreehouse.com/reading-files-using-the-html5-filereader-api

    There are samples there.

    Wednesday, May 6, 2015 1:05 PM
  • I think you need to check that your solution for storage will be OK. Crm stores all text fields as Unicode, which is a double-byte character set, which may cause problems. Also, binary files may include characters that will cause encoding problems - Crm stores file contents as a Base64-encoded string to avoid these issues, and you may need to consider something similar

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Wednesday, May 6, 2015 2:23 PM
    Moderator