Bringing data from Accounts to Contacts (and back)
-
Thursday, February 26, 2009 10:29 PMHello...
I have a client who wants to bring into the Account record the phone number and the email address of the Primary Contact for that Account.
I know I need to create, on the Account record, fields to contain this data (PrimaryContactPhone and PrimaryContactEmail, for instance). I'm not sure what TYPE of field this should be. Further, is there MAPPING to be done, 1 to Many, Many to 1.....
Essentially, when my client chooses a Primary contact for an Account, he wants two (or more) OTHER fields to populate with Data from the Contact record.
Any ideas?
Thanks,
Todd
Todd Zedak OH
All Replies
-
Friday, February 27, 2009 1:46 AM
Hi Todd,
The TYPE of field on the Account Form must be the same TYPE of field as in the Contact Form for the data you want bring over.To bring datas from Contact into Account form, you need to use Javascript with SOAP XML to execute Web service method for retrieve data. And to help you develop the SOAP XML message you can use Fiddler to capture the CRM SOAP XML.
This page show you an example of how to do this http://technet.microsoft.com/en-us/library/cc677073.aspx
Good Luck
Andy
- Proposed As Answer by Andy Hung Friday, February 27, 2009 1:46 AM
-
Friday, February 27, 2009 2:06 AM
Alternatively, a workflow on the change of the account's primary contact should do the job. When this changes, populate the accounts fields with their primary contact equivalents.Leon Tribe
Want to hear me talk about all things CRM? Check out my blog- Proposed As Answer by Leon TribeMVP Friday, February 27, 2009 2:07 AM
-
Friday, February 27, 2009 6:14 PM
This function will help you to get an attribute from a parent entity. In case of a primary contact in an account the parent of the Account is the Primary Contact/* ************************************************************* */
/* GET ATTRIBUTE FROM ANOTHER ETNITY FUNCTION */
/* ************************************************************* */lookupvalue = function GetAttributeValueFromID(sEntityName, sGUID, sAttributeName)
{
var sXml = "";
var oXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
var serverurl = window.location.protocol+"//"+window.location.host;
/*set up the SOAP message*/
sXml += "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
sXml += "<soap:Envelope" + " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"";
sXml += " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
sXml += " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";
sXml += "<soap:Body>";
sXml += "<entityName" + " xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" + sEntityName +
"</entityName>";
sXml += "<id" +" xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" + sGUID + "</id>";
sXml += "<columnSet" + " xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\""
sXml += " xmlns:q=\"http://schemas.microsoft.com/crm/2006/Query\""
sXml += " xsi:type=\"q:ColumnSet\"><q:Attributes><q:Attribute>" + sAttributeName + "</q:Attribute></q:Attributes></columnSet>";
sXml += "</soap:Body>";
sXml += "</soap:Envelope>";
/* send the message to the CRM Web service*/
oXmlHttp.Open("POST", serverurl + "/MsCrmServices/2006/CrmService.asmx",false);
oXmlHttp.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2006/WebServices/Retrieve");
oXmlHttp.setRequestHeader("Content-Type", "text/xml;charset=utf-8");
oXmlHttp.setRequestHeader("Content-Length", sXml.length);
oXmlHttp.send(sXml);
/* retrieve response and find attribute value*/
var result = oXmlHttp.responseXML.selectSingleNode("//q1:" + sAttributeName);
if (result == null)
{
return "";
}
else
{
return result.text;
}
};