HI Everyone
Business scenario : I created a custom field Get address Check box in Contact form,
when check box is checked i need get the address of selected account id and to display that in contact address.
for this i wrote javascript which fires when checkbox is checcked.
Javascript :
function GetAddress() {
if (Xrm.Page.getControl("parentcustomerid") != null) {
if (Xrm.Page.getAttribute("parentcustomerid").getValue() != null && Xrm.Page.getAttribute("parentcustomerid").getValue()[0].id != null) {
var customerId = Xrm.Page.getAttribute("parentcustomerid").getValue()[0].id;
var customerType = Xrm.Page.getAttribute("parentcustomerid").getValue()[0].entityType;
var serverUrl = Xrm.Page.context.getServerUrl();
if (customerType == "account") {
var retrievestring = serverUrl + "/xrmservices/2011/OrganizationData.svc/AccountSet?$filter=AccountId eq(guid'" + parentcustomerid+ "')";
var recordinfo = Retrieve(retrievestring);
if (recordinfo != null) {
var accountAddressAttributes = [recordinfo.results[0].Address1_Name, recordinfo.results[0].Address1_Line1, recordinfo.results[0].Address1_Line2,
recordinfo.results[0].Address1_Line3, recordinfo.results[0].Address1_City, recordinfo.results[0].Address1_StateOrProvince, recordinfo.results[0].Address1_Country,
recordinfo.results[0].Address1_Telephone1, recordinfo.results[0].Address1_PostalCode, recordinfo.results[0].new_District, recordinfo.results[0].new_Landmark];
Xrm.Page.getAttribute("address1_line1").setValue(recordinfo.results[0].Address1_Line1);
Xrm.Page.getAttribute("address1_line2").setValue(recordinfo.results[0].Address1_Line2);
Xrm.Page.getAttribute("address1_line3").setValue(recordinfo.results[0].Address1_Line3);
Xrm.Page.getAttribute("address1_city").setValue(recordinfo.results[0].Address1_City);
Xrm.Page.getAttribute("address1_stateorprovince").setValue(recordinfo.results[0].Address1_StateOrProvince);
Xrm.Page.getAttribute("address1_country").setValue(recordinfo.results[0].Address1_Country);
Xrm.Page.getAttribute("address1_postalcode").setValue(recordinfo.results[0].Address1_PostalCode);
Xrm.Page.data.entity.save();
Reply
}
I am getting Following script error
*This post is locked for comments