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 NAV (Archived)

How to insert DataUri in Text to Blob in NAV 2018 AL

(0) ShareShare
ReportReport
Posted on by 3,967

Hi,

I've created a JavaScript function ControlAdd-in which return a DataUri in Text, and save it in BLOB using AL extensions. 
I've tried using Text Datatype but the uri exceeds 250 characters. Thus, cannot store it as a text.

*This post is locked for comments

I have the same question (0)
  • Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    You can store it as a BLOB and convert/deconvert it as needed. Check here:

    [View:https://stackoverflow.com/questions/23150333/html5-javascript-dataurl-to-blob-blob-to-dataurl]

  • Olister Rumao Profile Picture
    3,967 on at

    Hi Stefano,

    I've converted  canvas to DataUri which is a text but since it exceeds 250 characters, it cannot be stored as text. Is it possible to convert Text having length >2500 to blob in AL??

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    Text fields on tables have this limit. I think you can also directly save the Canvas as BLOB from JS. There are samples to do so on the net.

  • Olister Rumao Profile Picture
    3,967 on at

    Hi Stefano,

    Tried that as well but there is event trigger from JS to AL which doesnt allow BLOB as its parameter.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    What event do you mean? It's quite difficult without seeing the code.

    Another idea could be to save the image as a temporary file and then from AL store it on a BLOB field.

  • Olister Rumao Profile Picture
    3,967 on at

    Let me explain the scenario

    Scenario:

    In NAV 2017 we used a Signature Control Add-in. We created the signature add-in with its core as a canvas which was created using Javascript. The interaction with the Javascript was done with the help of events i.e ClearSignature Event, AcceptSignature Event. These events send the data in the form MemoryStream. In NAV 2018 we've used DataUri to send data via the AcceptSignature Event. As the event which is called from Javascript doesn't allow parameter as a BLOB file in AL.

    Is there a way to convert the DataUri which is greater than 2500 characters be converted to BLOB?

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    You can save the DataUri in a BigText variable and then save it to a BLOB field. Something like:

    myTable.BlobField.CREATEOUTSTREAM(outstr);

    varBigText.WRITE(outstr);

    myTable.INSERT;

  • Olister Rumao Profile Picture
    3,967 on at

    Hi Stefano,

    It worked. But I'm facing another issue as to convert the DataUri to Memory Stream. Can this be done through azure functions assuming that we can convert in some way and then store it as a BLOB.

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    Yes Azure Function could be a solution for converting MemoryStream. In NAV 2018 you've also codeunit 704 for handling MemoryStream objects.

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 NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans