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
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.
Hi Kyi Moh,
Yes, please refer to this:
internet explorer - Save base64 string as PDF at client side with JavaScript - Stack Overflow
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
Hi Kyi Moh,
Yes, that's correct. You can try the code in the link.
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
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
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
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.
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
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?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156