Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Retrieve Base64 Value of EntityImage

Posted on by Microsoft Employee

Hi

I would like to use the entityimage of a custom entity in an SSRS report.

As far as understand, I need to create a multi-line text box and retrieve the Base64 values of the entity image and use this value in my SSRS report.

I do not want to write a plug-in to retrieve the Base64 value and would prefer to do this with JavaScript or a workflow rule.

Does anyone have any suggestions on the JavaScript that may be able to copy the Base64 value of the entityimage and populate a multi-line text box?

Thanks
Tony

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve Base64 Value of EntityImage

    Hi Justin

    Thanks so much for your response. It was really so easy to use the Web API.

    This script worked perfectly for me..

    function PopulateEntityImageBase64() {

       debugger;

       var isCreateForm = Xrm.Page.ui.getFormType() == 1;

       if (!isCreateForm) {

               var serverURL = Xrm.Page.context.getClientUrl();

               var queryEntity = "ks_portfolios";

               var Guid = Xrm.Page.data.entity.getId();

               var selectOptions = "$select=entityimage";

               var req = new XMLHttpRequest();

               req.open("GET", encodeURI(serverURL + "/api/data/v8.2/" + queryEntity + "(" + Guid + ")?" + selectOptions), true);

               req.setRequestHeader("OData-MaxVersion", "4.0");

               req.setRequestHeader("OData-Version", "4.0");

               req.setRequestHeader("Accept", "application/json");

               req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

               req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");

               req.onreadystatechange = function () {

                   if (this.readyState === 4) {

                       req.onreadystatechange = null;

                       if (this.status === 200) {

                           var result = JSON.parse(this.response);

                           var entityimage = result["entityimage"];

                           Xrm.Page.getAttribute('new_entityimagebase64').setValue(entityimage);

                       }

                       else {

                       }

                   }

               };

               req.send();

           }

    }

    Really so easy with JS and the Web API.

    Thanks again!

  • Verified answer
    Justinjose Profile Picture
    Justinjose 2,707 on at
    RE: Retrieve Base64 Value of EntityImage

    Hi Tony,

    I am not sure this is what you looking for. You can get entity image Base64 using Web Api Java Script. Below the result what i got

    @odata.context:"https://m365x324343.crm11.dynamics.com/api/data/v8.2/$metadata#",
    value:[
    {
    @odata.etag:"W/"1153013"",
    createdon@OData.Community.Display.V1.FormattedValue:"5/31/2018 3:45 PM",
    createdon:"2018-05-31T15:45:12Z",
    importsequencenumber: null ,
    entityimageid: null ,
    utcconversiontimezonecode: null ,
    entityimage_timestamp: null ,
    entityimage_url: null ,
    _owningteam_value: null ,
    _modifiedonbehalfby_value: null ,
    _createdonbehalfby_value: null ,
    timezoneruleversionnumber: null ,
    entityimage: null ,
    }
    ]

    Thanks

    Justin Jose

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Retrieve Base64 Value of EntityImage

    Hello Tony,

    I'm afraid  you will have to use .Net and plugins.

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans