Hi, can you point out the issues in this function
function copyaddress() {
try {
// Copies address information from shiptocontact to shiptoaddress fields
var shipcontact = new Array();
shipcontact = Xrm.Page.getAttribute("new_shiptocontact").getValue(); //new_information is a relationship's name
//if (shipcontact[0]!=null)
if (shipcontact != null) {
var contactid = shipcontact[0].id;
var authenticationHeader = GenerateAuthenticationHeader();
var xml = "<?xml version='1.0' encoding='utf-8'?>" +
"<soap:Envelope xmlns:soap='schemas.xmlsoap.org/.../&;" +
" xmlns:xsi='www.w3.org/.../XMLSchema-instance&;" +
" xmlns:xsd='www.w3.org/.../XMLSchema&;>" +
authenticationHeader +
"<soap:Body>" +
"<Retrieve xmlns='schemas.microsoft.com/.../WebServices&;>" +
"<entityName>contact</entityName>" +
"<id>" + contactid + "</id>" +
"<columnSet xmlns:q1='schemas.microsoft.com/.../Query&; xsi:type='q1:ColumnSet'>" +
"<q1:Attributes>" +
"<q1:Attribute>address1_line1</q1:Attribute>" +
"<q1:Attribute>address1_line2</q1:Attribute>" +
"<q1:Attribute>address1_city</q1:Attribute>" +
"<q1:Attribute>address1_stateorprovince</q1:Attribute>" +
"<q1:Attribute>address1_postalcode</q1:Attribute>" +
"<q1:Attribute>address1_country</q1:Attribute>" +
"<q1:Attribute>telephone1</q1:Attribute>" +
"<q1:Attribute>emailaddress1</q1:Attribute>" +
"</q1:Attributes>" +
"</columnSet>" +
"</Retrieve>" +
"</soap:Body>" +
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction", "schemas.microsoft.com/.../Retrieve");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0) {
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
else {
// Blank fields before editing new values
Xrm.Page.getAttribute("new_shipaddress1").setValue("");
Xrm.Page.getAttribute("new_shipaddress2").setValue("");
Xrm.Page.getAttribute("new_shipcity").setValue("");
Xrm.Page.getAttribute("new_shiptostate").setValue("");
Xrm.Page.getAttribute("new_shipzip").setValue("");
Xrm.Page.getAttribute("new_shiptocountry").setValue("");
Xrm.Page.getAttribute("new_phone").setValue("");
Xrm.Page.getAttribute("new_email").setValue("");
// var a=resultXml.selectSingleNode("//q1:address1_line1").nodeTypedValue;
// if(a!=null || a!=""){
// Xrm.Page.getAttribute("new_shipaddress1").setValue(a);
// }
if (resultXml.selectSingleNode("//q1:address1_line1") != null)
crmForm.all.new_shipaddress1.DataValue = resultXml.selectSingleNode("//q1:address1_line1").nodeTypedValue;
if (resultXml.selectSingleNode("//q1:address1_line2") != null)
crmForm.all.new_shipaddress2.DataValue = resultXml.selectSingleNode("//q1:address1_line2").nodeTypedValue;
if (resultXml.selectSingleNode("//q1:address1_city") != null)
crmForm.all.new_shipcity.DataValue = resultXml.selectSingleNode("//q1:address1_city").nodeTypedValue;
if (resultXml.selectSingleNode("//q1:address1_stateorprovince") != null)
crmForm.all.new_shiptostate.DataValue = resultXml.selectSingleNode("//q1:address1_stateorprovince").nodeTypedValue;
if (resultXml.selectSingleNode("//q1:address1_postalcode") != null)
crmForm.all.new_shipzip.DataValue = resultXml.selectSingleNode("//q1:address1_postalcode").nodeTypedValue;
if (resultXml.selectSingleNode("//q1:emailaddress1") != null)
crmForm.all.new_email.DataValue = resultXml.selectSingleNode("//q1:emailaddress1").nodeTypedValue;
if (resultXml.selectSingleNode("//q1:address1_country") != null)
crmForm.all.new_shiptocountry.DataValue = resultXml.selectSingleNode("//q1:address1_country").nodeTypedValue;
if (resultXml.selectSingleNode("//q1:telephone1") != null)
crmForm.all.new_phone.DataValue = resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue;
}
}
else {
// Blank fields before editing new values
Xrm.Page.getAttribute("new_shipaddress1").setValue("");
Xrm.Page.getAttribute("new_shipaddress2").setValue("");
Xrm.Page.getAttribute("new_shipcity").setValue("");
Xrm.Page.getAttribute("new_shiptostate").setValue("");
Xrm.Page.getAttribute("new_shipzip").setValue("");
Xrm.Page.getAttribute("new_shiptocountry").setValue("");
Xrm.Page.getAttribute("new_phone").setValue("");
Xrm.Page.getAttribute("new_email").setValue("");
}
}
catch (err) {
}
}
function copycontact() {
//check if box is checked
var myAttribute = "new_shiptosame";
var myControl = Xrm.Page.ui.controls.get(myAttribute);
var myCheckboxValue = myControl.getAttribute().getValue();
// returns True or false
if (myCheckboxValue == true) {
//Get a lookup value
var lookupItem = new Array();
lookupItem = Xrm.Page.getAttribute("new_contact").getValue();
if (lookupItem != null) {
//Get the current values
var name = lookupItem[0].name;
var guid = lookupItem[0].id;
var entType = lookupItem[0].entityType;
//Set a lookup value
var value = new Array();
value[0] = new Object();
value[0].id = guid;
value[0].name = name;
value[0].entityType = entType;
//Set the Field Value
Xrm.Page.getAttribute("new_shiptocontact").setValue(value);
}
copyaddress()
}
}
function displayrequired() {
var lookupObject = Xrm.Page.getAttribute("new_product");
if (lookupObject != null) {
var lookUpObjectValue = lookupObject.getValue();
}
if (lookUpObjectValue != null) {
var lookuptextvalue = lookUpObjectValue[0].name;
}
if (lookuptextvalue == "J3500") {
Xrm.Page.getAttribute("new_evaldisplaytype").setRequiredLevel("required");
}
else if (lookuptextvalue != "J3500") {
Xrm.Page.getAttribute("new_evaldisplaytype").setRequiredLevel("none");
}
}
function activate_CopyPrimaryContact() {
Xrm.Page.getControl("new_shiptosame").onclick = function () {
Xrm.Page.getAttribute("new_shiptosame").fireOnChange();
}
// crmForm.all.new_shiptosame.onclick = function () {
// crmForm.all.new_shiptosame.FireOnChange();
// };
}
Can you confirm about for new web service path?
Thanks,