javascript - getting an error Object doesn't support property or method 'setSrc' in web Resource in CRM 2011 -
i have used webresource on page , getting error object doesn't support property or method 'setsrc' in javascript
can please me
my actual code
function getimage() { var entityid = xrm.page.data.entity.getid(); var profilepictureelement = xrm.page.getcontrol("webresource_profilepicture"); if (entityid) { var odataquery = getserverurl() + "/xrmservices/2011/organizationdata.svc" + "/annotationset?$top=1&$select=annotationid,documentbody,mimetype&" + "$orderby=modifiedon desc&$filter=objectid/id eq guid'" + entityid + "' , isdocument eq true , subject eq 'profile picture'" + " , startswith(mimetype,'image/') "; $.ajax({ type: "get", contenttype: "application/json; charset=utf-8", datatype: "json", url: odataquery, beforesend: function (request) { request.setrequestheader("accept", "application/json"); }, success: function (data, textstatus, request) { if (data.d.results.length > 0) { var mimetype = data.d.results[0].mimetype; var body = data.d.results[0].documentbody; // set src attribute of default profile picture web resource. // here use datauri schema has 32kb limit in ie8 , doesn't support ie <= 7. profilepictureelement.setsrc("data:" + mimetype + ";base64," + body); } }, error: function (request, status, exception) { } }); } } function getserverurl() { var serverurl = xrm.page.context.getserverurl(); // trim trailing forward slash in url return serverurl.replace(/\/*$/, ""); } you can refer whole article here http://blogs.msdn.com/b/crm/archive/2011/09/28/displaying-a-contact-s-facebook-picture-in-microsoft-dynamics-crm-2011.aspx?commentposted=true#commentmessage
looks methods getsrc , setsrc can used against web resource when refer html content.
if web resource image, crm use img tag display picture.
if want make code working need retrieve img element , assign src property manually:
instead of
profilepictureelement.setsrc("data:" + mimetype + ";base64," + body); you need write
var profilepicture = document.getelementbyid("webresource_profilepicture"); profilepicture.setattribute("src","data:" + mimetype + ";base64," + body); note: this unsupported customization
Comments
Post a Comment