Search code examples
javascriptdynamics-crm-2011dynamics-crmcrm

Form OnLoad event, Store and display image on iframe


I am newbie to CRM. I want to add javascript function on form onload event and want to read the loading forms field A which contains the image value as a string and wants to display on iFrame. is it possible in CRM 2011. I am using the below function. it gives error undefined for photo.src. How can i achieve this.

function Load_Images(){

  var photodata = Xrm.Page.getAttribute("photo_data").getValue();


  var customHtml = Xrm.Page.ui.controls.get("WebResource_htmldoc");
  var destination = customHtml.getObject().contentWindow.document;

  var photo =  destination.getElementById("photo");

  photo.src = "data:image/jpeg;base64," + photodata ;   

}


Solution

  • You can remove the OnLoad event handler from the form and modify your html web resource. In your html file, you can just reference the field from your CRM form using something like:

    window.parent.Xrm.Page.getAttribute()