Skip to main content

Notifications

Service | Customer Service, Contact Center, Fie...
Suggested answer

How to show image from base64 string on a case form

Posted on by 60

Dear All,

Is there a way to convert image on a case form from base64 string returned from other API.

I need your guys help

Please help the way.

Best Regards,

Kyi Moh

  • CRMJetty Profile Picture
    CRMJetty 3,508 on at
    RE: How to show image from base64 string on a case form

    Hi Kyi,

    You can display image using web resource, for that first you need to create web resource(HTML and JS) and then you can use it in CRM form to display image. The logic of get base64 and convert to image will be written in web resource and on load of form you can add that web resource in form, so when form will be load, in web resource base64 will be retrieve from the 3rd party API and convert it to image and display it in form. You can also do that process on click of button, for that you need to open web resource on click of button.

    References:

    Create HTML/JS web resource in CRM:
    https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/webpage-html-web-resources?view=op-9-1
    https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/script-jscript-web-resources?view=op-9-1
    https://www.c-sharpcorner.com/article/dynamics-365-html-and-javascript-resources/#:~:text=Go%20to%20Form%20%3E%3E%20Click%20on%20Form%20Properties.&text=Click%20on%20%22%2BAdd%20%22.,Lookup%20window%20will%20pop%20up.&text=If%20there%20are%20any%20JS,add%20it%20to%20the%20form

    Add web resource in CRM form onload event:
    https://carldesouza.com/dynamics-365-html-web-resource-example/

    Open web resource on click of ribbon button in CRM:
    https://carldesouza.com/open-html-page-button-ribbon-workbench/

    Convert base64 to image in JS/jQuery:
    https://www.codegrepper.com/code-examples/javascript/how+to+convert+image+to+base64+in+javascript

    https://stackoverflow.com/questions/6150289/how-can-i-convert-an-image-into-base64-string-using-javascript

    I hope it helps,

    Thanks.

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to show image from base64 string on a case form

    Hi Kyi Moh,

    Yes, please refer to this:

    internet explorer - Save base64 string as PDF at client side with JavaScript - Stack Overflow

  • Kyi Moh Profile Picture
    Kyi Moh 60 on at
    RE: How to show image from base64 string on a case form

    Hi Steve Zhao,

    Thanks so much. I will try it out

    Also I would like to know that can we convert base64 string to PDF file using JavaScript?

    Best Regards,

    Kyi Moh

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to show image from base64 string on a case form

    Hi Kyi Moh,

    Yes, that's correct. You can try the code in the link.

  • Kyi Moh Profile Picture
    Kyi Moh 60 on at
    RE: How to show image from base64 string on a case form

    Hi Steve Zhao,

    So, we can convert base64 string to image at client side using JavaScript. right?

    Thank you for your reply.

    Best Regards,

    Kyi Moh

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to show image from base64 string on a case form

    Hi Kyi Moh,

    I see. So you can send AJAX request to get the base64string from other API in the html web resource when the document is ready or  View Image button is clicked(This is up to you).

    Then you could get the base64string of the email.

    Finally, create an image object and add to your html  is ok.

    convert base64 to image in javascript/jquery - Stack Overflow

  • Kyi Moh Profile Picture
    Kyi Moh 60 on at
    RE: How to show image from base64 string on a case form

    HI Steve Zhao,

    My requirement is that there are one button(View Image) and one html form (Image Form) written by html web resource at CRM case form.

    When click View Image button, Image Form will be show up.

    I have to call other API to get base64string at Image Form load event.

    After get base64string, I need to convert it to image at Image Form.

    I don't save those image at CRM side because of capacity problem.

    So, I just want to convert image from base64 on the fly.

    Thank you so much for your reply help,

    Best Regards,

    Kyi Moh

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to show image from base64 string on a case form

    Hi Kyi Moh,

    Did you create a html web resource and insert it to the case form? If so, you can direct convert it to image and append to your html web resource.

  • Kyi Moh Profile Picture
    Kyi Moh 60 on at
    RE: How to show image from base64 string on a case form

    Hi Steve Zhao,

    I don't have custom column.

    I have custom html button "View Image".

    When click View Image button, I will call the other Third Party API to get base64 string.

    That API will return base64 string.

    I need to convert base64 string returned from API to image at case form.

    But, I don't know the way of it.

    Thank you so much.

    Best Regards,

    Kyi Moh

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to show image from base64 string on a case form

    Hi Kyi Moh,

    Do you mean you have a custom column which stores base64 string, and you want to convert it to image and show on the case form?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans