Asked by:
crm 2013 profile image change?

Question
-
Hi,
May I change profile image onload by using javascript?
Wednesday, March 5, 2014 10:30 AM
All replies
-
Hi Aamir,
Yes, you can change the image. Have a look here http://dynamicscrmgirl.wordpress.com/2014/01/26/crm-2013-javascript-update-an-entity-image-of-a-record-using-odatarest-endpoint-without-jquery/
Wednesday, March 5, 2014 10:33 AM -
Hi Dynamotion,
Kindly tell me in step by step.
I have an entity "new_dealer" and have an optionset is "new_status" that contain two items like"available" and "not available"
and two images as WebResource "new_image1" and "new_image2". My scenario is :
if (new_status== "available")
then
set entityimage is change into "new_image1
else if (new_status=="not available")
{
set entityimage is change into "new_image2"
}
Please help me out and give me all steps how can i create javascript.. :(
Thursday, March 6, 2014 4:34 AM -
Hi Aamir,
The link I provided does something like that, but I'll still list down the actual modified code for you according to your requirement. Use the code snippets as guided in the link I provided.
//Hook this method to the "OnChange" event of "new_status" field OnAttributeChange_Status: function () { var dealerId = Xrm.Page.data.entity.getId(); var statusValue = Xrm.Page.getAttribute("new_status").getValue(); if (statusValue == "optionset_value_for_available") { //retrieve image new_image1.jpg and update dealer record "EntityImage" attribute this.UpdateDealerRecordWithNewImage(dealerId, "new_image1.jpg"); } else if (statusValue == "optionset_value_for_not_available") { //retrieve image new_image2.jpg and update dealer record "EntityImage" attribute this.UpdateDealerRecordWithNewImage(dealerId, "new_image2.jpg"); } },
UpdateDealerRecordWithNewImage: function(dealerId, webResourceName){ this.GetImageWebResource( dealerId, webResourceName, this.UpdateDealerRecord ); },
GetImageWebResource: function (dealerId, imageName, successCallback) { //OData URI to get address information from parent account record var oDataURI = Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/" + "WebResourceSet" + "?$filter=" + "Name eq '" + imageName + "'" + "&$select=Name,Content"; //Synchronous XMLHttpRequest to retrieve account record var req = new XMLHttpRequest(); req.open("GET", encodeURI(oDataURI), false); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.onreadystatechange = function () { //debugger; if (this.readyState == 4 /* complete */) { req.onreadystatechange = null; //avoids memory leaks if (this.status == 200) { //parse the response string as a JSON object into the successCallback method. successCallback(dealerId, JSON.parse(this.responseText).d); } else { var errorMsg1 = "GetImageWebResource Error: cannot retrieve image with name = " + imageName + "."; //display a non-blocking alert dialog Xrm.Utility.alertDialog(errorMsg1, function () { }); } } }; req.send(); },
UpdateDealerRecord: function (recordId, webResource) { var new_dealer = {}; new_dealer.EntityImage = webResource.results[0].Content; //byte[] content of the web resource var jsonDealer = JSON.stringify(new_dealer); //OData URI var oDataURI = Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/" + "new_dealertSet(guid'" + recordId + "')"; //Synchronous post var req = new XMLHttpRequest(); req.open("POST", encodeURI(oDataURI), false); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.setRequestHeader("X-HTTP-Method", "MERGE"); req.onreadystatechange = function () { //debugger; if (this.readyState == 4 /* complete */) { req.onreadystatechange = null; if (this.status == 204 || this.status == 1223) { //reloads the dealer record window.location.reload(false); } else { var errorMsg2 = "UpdateDealerRecord Error: Cannot update dealer record with dealerId = " + recordId + "."; //display a non-blocking alert dialog Xrm.Utility.alertDialog(errorMsg2, function () { }); } } }; req.send(jsonDealer); }
You can write down this methods in a JavsScript file and upload it like you uploaded the images as web resources. Once you have uploaded the JavaScript files, you can link them to your field on change event from the CRM form customization.
Admin QuikView Solution for CRM 2013
- Edited by Anupam Bishui Thursday, March 6, 2014 9:45 AM
Thursday, March 6, 2014 9:43 AM -
Hi Amir,
Just refer the LINK given above.You can call those function in setProfileImage as given below onLoad of your form.
function setProfileImage() { if(Xrm.Page.getAttribute("new_status").getValue() == 1)// Replace "1" with your "available" item Value { //retrieve image Image1.jpg below "new_Image1.jpg" webResourceName .So replace it with appropriate one this.UpdateContactRecordWithNewImage(contactId, "new_Image1.jpg"); } else { //retrieve image Image2.jpg this.UpdateContactRecordWithNewImage(contactId, "new_Image2.jpg"); } }
Hope this helps
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Mohammad Yusuf Ansari http://microxrm.blogspot.in
- Edited by Mohammad Yusuf Ansari Thursday, March 6, 2014 6:50 PM
Thursday, March 6, 2014 9:45 AM -
Hi Dynamotion,
I have created four javascripts as u told me
first i created a script name "new_setProfileImage" onload event
//Hook this method to the "OnChange" event of "new_status" field OnAttributeChange_Status: function () { var dealerId = Xrm.Page.data.entity.getId(); var statusValue = Xrm.Page.getAttribute("new_status").getValue(); if (statusValue == "optionset_value_for_available") { //retrieve image new_image1.jpg and update dealer record "EntityImage" attribute this.UpdateDealerRecordWithNewImage(dealerId, "new_image1.jpg"); } else if (statusValue == "optionset_value_for_not_available") { //retrieve image new_image2.jpg and update dealer record "EntityImage" attribute this.UpdateDealerRecordWithNewImage(dealerId, "new_image2.jpg"); } },
and then created javascript name "UpdateDealerRecordWithNewImage"
UpdateDealerRecordWithNewImage: function(dealerId, webResourceName){ this.GetImageWebResource( dealerId, webResourceName, this.UpdateDealerRecord ); },
then created another script name"GetImageWebResource"
GetImageWebResource: function (dealerId, imageName, successCallback) { //OData URI to get address information from parent account record var oDataURI = Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/" + "WebResourceSet" + "?$filter=" + "Name eq '" + imageName + "'" + "&$select=Name,Content"; //Synchronous XMLHttpRequest to retrieve account record var req = new XMLHttpRequest(); req.open("GET", encodeURI(oDataURI), false); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.onreadystatechange = function () { //debugger; if (this.readyState == 4 /* complete */) { req.onreadystatechange = null; //avoids memory leaks if (this.status == 200) { //parse the response string as a JSON object into the successCallback method. successCallback(dealerId, JSON.parse(this.responseText).d); } else { var errorMsg1 = "GetImageWebResource Error: cannot retrieve image with name = " + imageName + "."; //display a non-blocking alert dialog Xrm.Utility.alertDialog(errorMsg1, function () { }); } } }; req.send(); },
and then created another script name "UpdateDealerRecord"
UpdateDealerRecord: function (recordId, webResource) { var new_dealer = {}; new_dealer.EntityImage = webResource.results[0].Content; //byte[] content of the web resource var jsonDealer = JSON.stringify(new_dealer); //OData URI var oDataURI = Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/" + "new_dealertSet(guid'" + recordId + "')"; //Synchronous post var req = new XMLHttpRequest(); req.open("POST", encodeURI(oDataURI), false); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.setRequestHeader("X-HTTP-Method", "MERGE"); req.onreadystatechange = function () { //debugger; if (this.readyState == 4 /* complete */) { req.onreadystatechange = null; if (this.status == 204 || this.status == 1223) { //reloads the dealer record window.location.reload(false); } else { var errorMsg2 = "UpdateDealerRecord Error: Cannot update dealer record with dealerId = " + recordId + "."; //display a non-blocking alert dialog Xrm.Utility.alertDialog(errorMsg2, function () { }); } } }; req.send(jsonDealer); }
After that i open any record error is occured on page load
There was an error with this field's customized event
field:window
event:onload
error:Undefined
- Edited by Aamir Hijazi Friday, March 7, 2014 9:30 AM
Friday, March 7, 2014 9:28 AM -
Hi Mohammad Yusuf,
Kindly help me out there is an error on page load
I followed these steps:
first i created a script name "new_setProfileImage" onload event
//Hook this method to the "OnChange" event of "new_status" field OnAttributeChange_Status: function () { var dealerId = Xrm.Page.data.entity.getId(); var statusValue = Xrm.Page.getAttribute("new_status").getValue(); if (statusValue == "optionset_value_for_available") { //retrieve image new_image1.jpg and update dealer record "EntityImage" attribute this.UpdateDealerRecordWithNewImage(dealerId, "new_image1.jpg"); } else if (statusValue == "optionset_value_for_not_available") { //retrieve image new_image2.jpg and update dealer record "EntityImage" attribute this.UpdateDealerRecordWithNewImage(dealerId, "new_image2.jpg"); } },
and then created javascript name "UpdateDealerRecordWithNewImage"
UpdateDealerRecordWithNewImage: function(dealerId, webResourceName){ this.GetImageWebResource( dealerId, webResourceName, this.UpdateDealerRecord ); },
then created another script name"GetImageWebResource"
GetImageWebResource: function (dealerId, imageName, successCallback) { //OData URI to get address information from parent account record var oDataURI = Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/" + "WebResourceSet" + "?$filter=" + "Name eq '" + imageName + "'" + "&$select=Name,Content"; //Synchronous XMLHttpRequest to retrieve account record var req = new XMLHttpRequest(); req.open("GET", encodeURI(oDataURI), false); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.onreadystatechange = function () { //debugger; if (this.readyState == 4 /* complete */) { req.onreadystatechange = null; //avoids memory leaks if (this.status == 200) { //parse the response string as a JSON object into the successCallback method. successCallback(dealerId, JSON.parse(this.responseText).d); } else { var errorMsg1 = "GetImageWebResource Error: cannot retrieve image with name = " + imageName + "."; //display a non-blocking alert dialog Xrm.Utility.alertDialog(errorMsg1, function () { }); } } }; req.send(); },
and then created another script name "UpdateDealerRecord"
UpdateDealerRecord: function (recordId, webResource) { var new_dealer = {}; new_dealer.EntityImage = webResource.results[0].Content; //byte[] content of the web resource var jsonDealer = JSON.stringify(new_dealer); //OData URI var oDataURI = Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/" + "new_dealertSet(guid'" + recordId + "')"; //Synchronous post var req = new XMLHttpRequest(); req.open("POST", encodeURI(oDataURI), false); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.setRequestHeader("X-HTTP-Method", "MERGE"); req.onreadystatechange = function () { //debugger; if (this.readyState == 4 /* complete */) { req.onreadystatechange = null; if (this.status == 204 || this.status == 1223) { //reloads the dealer record window.location.reload(false); } else { var errorMsg2 = "UpdateDealerRecord Error: Cannot update dealer record with dealerId = " + recordId + "."; //display a non-blocking alert dialog Xrm.Utility.alertDialog(errorMsg2, function () { }); } } }; req.send(jsonDealer); }
After that i open any record error is occured on page load
There was an error with this field's customized event
field:window
event:onload
error:Undefined
Friday, March 7, 2014 9:35 AM -
Hi Aamir,
No need to put functions in different files. Put them all inside one single .js file and name it something like "new_setImageMethods". Once you have created that as web resource, open up the CRM form customization, go to properties and add the web resource file to your form library. Then double click your status field on the customization form and wire up that web resource with your field and set method as OnAttributeChange_Status on change event.
Friday, March 7, 2014 9:42 AM -
The implemention theory is that using REST API to update entity record in client side through Ajax. So first you need to build a Ajax proxy, second you need to build a Client Object as following:
var new_dealer = {};
new_dealer.EntityImage = webResource.results[0].Content; //byte[] contentAnd the last is submiting the client object to server.
Friday, March 7, 2014 9:55 AM -
Still error is occured... :(Friday, March 7, 2014 10:00 AM
-
Hi Dynamotion,
I followed those instructions which you told me but still there is some error occured. I have mentioned my steps which i used. Kindly check my all steps and tell me what mistake i am doing....
i wanted to change entity image according to status field if tatus value is "1", "new_image1.jpg" will display and if status value is "2" then "new_image2.jpg" will display
i have an entity name "new_dealer" with optionset field name "new_status"
i have added two images as web resource "new_image1.jpg" , "new_image2.jpg"
These are steps which i followed according to your instructions
first of all i added a web resource as javascript file name "new_setImageMethods"
//Hook this method to the "OnChange" event of "new_status" field
OnAttributeChange_Status: function () {
var dealerId = Xrm.Page.data.entity.getId();
var statusValue = Xrm.Page.getAttribute("new_status").getValue();
if (statusValue == 1)
{
//retrieve image new_image1.jpg and update dealer record "EntityImage" attribute
this.UpdateDealerRecordWithNewImage(dealerId, "new_image1.jpg");
}
else if (statusValue == 2)
{
//retrieve image new_image2.jpg and update dealer record "EntityImage" attribute
this.UpdateDealerRecordWithNewImage(dealerId, "new_image2.jpg");
}
},
UpdateDealerRecordWithNewImage: function(dealerId, webResourceName){
this.GetImageWebResource(
dealerId,
webResourceName,
this.UpdateDealerRecord
);
},
GetImageWebResource: function (dealerId, imageName, successCallback) {
//OData URI to get address information from parent account record
var oDataURI = Xrm.Page.context.getClientUrl()
+ "/XRMServices/2011/OrganizationData.svc/"
+ "WebResourceSet"
+ "?$filter="
+ "Name eq '" + imageName + "'"
+ "&$select=Name,Content";
//Synchronous XMLHttpRequest to retrieve account record
var req = new XMLHttpRequest();
req.open("GET", encodeURI(oDataURI), false);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
//debugger;
if (this.readyState == 4 /* complete */) {
req.onreadystatechange = null; //avoids memory leaks
if (this.status == 200) {
//parse the response string as a JSON object into the successCallback method.
successCallback(dealerId, JSON.parse(this.responseText).d);
}
else {
var errorMsg1 = "GetImageWebResource Error: cannot retrieve image with name = " + imageName + ".";
//display a non-blocking alert dialog
Xrm.Utility.alertDialog(errorMsg1, function () { });
}
}
};
req.send();
},
UpdateDealerRecord: function (recordId, webResource) {
var new_dealer = {};
new_dealer.EntityImage = webResource.results[0].Content; //byte[] content of the web resource
var jsonDealer = JSON.stringify(new_dealer);
//OData URI
var oDataURI = Xrm.Page.context.getClientUrl()
+ "/XRMServices/2011/OrganizationData.svc/"
+ "new_dealertSet(guid'" + recordId + "')";
//Synchronous post
var req = new XMLHttpRequest();
req.open("POST", encodeURI(oDataURI), false);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("X-HTTP-Method", "MERGE");
req.onreadystatechange = function () {
//debugger;
if (this.readyState == 4 /* complete */) {
req.onreadystatechange = null;
if (this.status == 204 || this.status == 1223) {
//reloads the dealer record
window.location.reload(false);
}
else {
var errorMsg2 = "UpdateDealerRecord Error: Cannot update dealer record with dealerId = " + recordId + ".";
//display a non-blocking alert dialog
Xrm.Utility.alertDialog(errorMsg2, function () { });
}
}
};
req.send(jsonDealer);
}
then i added the web resource file in form library and then double click on "new_status" field and set method "OnAttributeChange_Status" on change event
Friday, March 7, 2014 12:34 PM -
Anyone tell me what is the problem in my script
this error occured :
Microsoft Dynamics CRM Error Report Contents
<CrmScriptErrorReport>
<ReportVersion>1.0</ReportVersion>
<ScriptErrorDetails>
<Message>SyntaxError: function statement requires a name</Message>
<Line>2</Line>
<URL>/%7B635297960290000462%7D/WebResources/new_setimagemethods</URL>
<PageURL>/main.aspx?etc=10005&extraqs=%3fetc%3d10005&pagemode=iframe&pagetype=entityrecord</PageURL>
<Function></Function>
<CallStack>
</CallStack>
</ScriptErrorDetails>
<ClientInformation>
<BrowserUserAgent>Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0</BrowserUserAgent>
<BrowserLanguage>undefined</BrowserLanguage>
<SystemLanguage>undefined</SystemLanguage>
<UserLanguage>undefined</UserLanguage>
<ScreenResolution>1366x768</ScreenResolution>
<ClientName>Web</ClientName>
<ClientTime>2014-03-07T18:45:45</ClientTime>
</ClientInformation>
<ServerInformation>
<OrgLanguage>1033</OrgLanguage>
<OrgCulture>1033</OrgCulture>
<UserLanguage>1033</UserLanguage>
<UserCulture>1033</UserCulture>
<OrgID>{C7FF7F2E-913C-4BFA-B753-78F025F6FA6D}</OrgID>
<UserID>{B084C487-6A80-451D-AEF9-3A44DB8CE999}</UserID>
<CRMVersion>6.0.1.462</CRMVersion>
</ServerInformation>
</CrmScriptErrorReport>
please resolve my issue...
Friday, March 7, 2014 1:53 PM -
Hi Aamir,
Please could you replace "UpdateDealerRecord: function (recordId, webResource)" with "function UpdateDealerRecord (recordId, webResource)" and similarly for all the functions?
Friday, March 7, 2014 2:30 PM -
Yes I have replaced all functions:
//Hook this method to the "OnChange" event of "new_status" field
function OnAttributeChange_Status() {
var dealerId = Xrm.Page.data.entity.getId();
var statusValue = Xrm.Page.getAttribute("new_status").getValue();
if (statusValue == 1)
{
//retrieve image new_image1.jpg and update dealer record "EntityImage" attribute
this.UpdateDealerRecordWithNewImage(dealerId, "new_image1.jpg");
}
else if (statusValue == 2)
{
//retrieve image new_image2.jpg and update dealer record "EntityImage" attribute
this.UpdateDealerRecordWithNewImage(dealerId, "new_image2.jpg");
}
},
function UpdateDealerRecordWithNewImage(dealerId, webResourceName){
this.GetImageWebResource(
dealerId,
webResourceName,
this.UpdateDealerRecord
);
},
function GetImageWebResource(dealerId, imageName, successCallback) {
//OData URI to get address information from parent account record
var oDataURI = Xrm.Page.context.getClientUrl()
+ "/XRMServices/2011/OrganizationData.svc/"
+ "WebResourceSet"
+ "?$filter="
+ "Name eq '" + imageName + "'"
+ "&$select=Name,Content";
//Synchronous XMLHttpRequest to retrieve account record
var req = new XMLHttpRequest();
req.open("GET", encodeURI(oDataURI), false);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
//debugger;
if (this.readyState == 4 /* complete */) {
req.onreadystatechange = null; //avoids memory leaks
if (this.status == 200) {
//parse the response string as a JSON object into the successCallback method.
successCallback(dealerId, JSON.parse(this.responseText).d);
}
else {
var errorMsg1 = "GetImageWebResource Error: cannot retrieve image with name = " + imageName + ".";
//display a non-blocking alert dialog
Xrm.Utility.alertDialog(errorMsg1, function () { });
}
}
};
req.send();
},
function UpdateDealerRecord(recordId, webResource) {
var new_dealer = {};
new_dealer.EntityImage = webResource.results[0].Content; //byte[] content of the web resource
var jsonDealer = JSON.stringify(new_dealer);
//OData URI
var oDataURI = Xrm.Page.context.getClientUrl()
+ "/XRMServices/2011/OrganizationData.svc/"
+ "new_dealertSet(guid'" + recordId + "')";
//Synchronous post
var req = new XMLHttpRequest();
req.open("POST", encodeURI(oDataURI), false);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("X-HTTP-Method", "MERGE");
req.onreadystatechange = function () {
//debugger;
if (this.readyState == 4 /* complete */) {
req.onreadystatechange = null;
if (this.status == 204 || this.status == 1223) {
//reloads the dealer record
window.location.reload(false);
}
else {
var errorMsg2 = "UpdateDealerRecord Error: Cannot update dealer record with dealerId = " + recordId + ".";
//display a non-blocking alert dialog
Xrm.Utility.alertDialog(errorMsg2, function () { });
}
}
};
req.send(jsonDealer);
}but unfortunately still error is occured
Microsoft Dynamics CRM Error Report Contents
<CrmScriptErrorReport>
<ReportVersion>1.0</ReportVersion>
<ScriptErrorDetails>
<Message>SyntaxError: syntax error</Message>
<Line>19</Line>
<URL>/%7B635297997920000462%7D/WebResources/new_new_setimagemethods</URL>
<PageURL>/main.aspx?etc=10005&extraqs=%3f_gridType%3d10005%26etc%3d10005%26id%3d%257bA8EFB9D5-FEA5-E311-8AA2-6C3BE5A8174C%257d%26rskey%3d224860033&pagemode=iframe&pagetype=entityrecord&rskey=224860033</PageURL>
<Function></Function>
<CallStack>
</CallStack>
</ScriptErrorDetails>
<ClientInformation>
<BrowserUserAgent>Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0</BrowserUserAgent>
<BrowserLanguage>undefined</BrowserLanguage>
<SystemLanguage>undefined</SystemLanguage>
<UserLanguage>undefined</UserLanguage>
<ScreenResolution>1366x768</ScreenResolution>
<ClientName>Web</ClientName>
<ClientTime>2014-03-07T19:37:16</ClientTime>
</ClientInformation>
<ServerInformation>
<OrgLanguage>1033</OrgLanguage>
<OrgCulture>1033</OrgCulture>
<UserLanguage>1033</UserLanguage>
<UserCulture>1033</UserCulture>
<OrgID>{C7FF7F2E-913C-4BFA-B753-78F025F6FA6D}</OrgID>
<UserID>{B084C487-6A80-451D-AEF9-3A44DB8CE999}</UserID>
<CRMVersion>6.0.1.462</CRMVersion>
</ServerInformation>
</CrmScriptErrorReport>
Friday, March 7, 2014 2:40 PM -
Hi Aamir,
Remove the comma's after the functions. Like this
function OnAttributeChange_Status() { var dealerId = Xrm.Page.data.entity.getId(); var statusValue = Xrm.Page.getAttribute("new_status").getValue(); if (statusValue == 1) { //retrieve image new_image1.jpg and update dealer record "EntityImage" attribute this.UpdateDealerRecordWithNewImage(dealerId, "new_image1.jpg"); } else if (statusValue == 2) { //retrieve image new_image2.jpg and update dealer record "EntityImage" attribute this.UpdateDealerRecordWithNewImage(dealerId, "new_image2.jpg"); } },
to
function OnAttributeChange_Status() { var dealerId = Xrm.Page.data.entity.getId(); var statusValue = Xrm.Page.getAttribute("new_status").getValue(); if (statusValue == 1) { //retrieve image new_image1.jpg and update dealer record "EntityImage" attribute this.UpdateDealerRecordWithNewImage(dealerId, "new_image1.jpg"); } else if (statusValue == 2) { //retrieve image new_image2.jpg and update dealer record "EntityImage" attribute this.UpdateDealerRecordWithNewImage(dealerId, "new_image2.jpg"); } }
<http://mscrmhacks.com/admin-quikview-solution-crm-2013>Admin QuikView Solution for CRM 2013
- Edited by Anupam Bishui Friday, March 7, 2014 3:01 PM
Friday, March 7, 2014 3:00 PM -
Now I got an error after removing commas
I just want to update image with respect to status. when I update status then error is occured which is mentioned above.
Friday, March 7, 2014 3:09 PM -
What is the error that you're getting? Did you check that the JavaScript syntax is right? Also, did you try debugging and check where the error lies?Friday, March 7, 2014 3:22 PM
-
this is an error occured
Microsoft Dynamics CRM Error Report Contents
<CrmScriptErrorReport>
<ReportVersion>1.0</ReportVersion>
<ScriptErrorDetails>
<Message>SyntaxError: syntax error</Message>
<Line>19</Line>
<URL>/%7B635298013430000462%7D/WebResources/new_new_setimagemethods</URL>
<PageURL>/main.aspx?etc=10005&extraqs=%3f_gridType%3d10005%26etc%3d10005%26id%3d%257b03E7484E-CFA5-E311-B6CC-6C3BE5BD9AAC%257d%26rskey%3d446654111&pagemode=iframe&pagetype=entityrecord&rskey=446654111</PageURL>
<Function></Function>
<CallStack>
</CallStack>
</ScriptErrorDetails>
<ClientInformation>
<BrowserUserAgent>Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0</BrowserUserAgent>
<BrowserLanguage>undefined</BrowserLanguage>
<SystemLanguage>undefined</SystemLanguage>
<UserLanguage>undefined</UserLanguage>
<ScreenResolution>1366x768</ScreenResolution>
<ClientName>Web</ClientName>
<ClientTime>2014-03-07T20:11:55</ClientTime>
</ClientInformation>
<ServerInformation>
<OrgLanguage>1033</OrgLanguage>
<OrgCulture>1033</OrgCulture>
<UserLanguage>1033</UserLanguage>
<UserCulture>1033</UserCulture>
<OrgID>{C7FF7F2E-913C-4BFA-B753-78F025F6FA6D}</OrgID>
<UserID>{B084C487-6A80-451D-AEF9-3A44DB8CE999}</UserID>
<CRMVersion>6.0.1.462</CRMVersion>
</ServerInformation>
</CrmScriptErrorReport>
Friday, March 7, 2014 3:26 PM -
and kindly tell me how can i debug my script ?Friday, March 7, 2014 3:27 PM
-
Hi Aamir,
Uncheck "Disable Script Debugging" from IE settings under Advanced tab. Put the statement debugger; from where you want to debug the code (a good idea is to place it at the very beginning so you can test the complete flow). Change the Status value and you should see a popup asking you to debug.
For details see here http://msdn.microsoft.com/en-us/library/dd565625(v=vs.85).aspx
Friday, March 7, 2014 3:33 PM -
Hi Dynamotion,
Still I got same error
Now tell me what should I do for resloving my issue? I will be thankful to you
Friday, March 7, 2014 3:48 PM -
Hi Dynamotion,
Kindly tell me that is this scripts work for online crm 2013?
Friday, March 7, 2014 10:21 PM -
Hi,
I debugged my code i got error
Saturday, March 8, 2014 5:14 AM