I'm trying to get the Campaign Lookup from the Opportunity to flow over to the appointment when it's created off the Opportunity. I have the following code and it populated the field with a campaign and no errors but it was a new campaing not the one from the Opportunity. So the code is close and looking for a brighter mind to say where my mistake is.
We are using Dynamics 4.0
Thanks
// Populate Originating Campaign ------------------------------------------------------------ var serviceLocation = prependOrgName("/ISV/CRMServices/CrmRetrievalServiceIndustry.asmx"); var soapXml='<?xml version="1.0" encoding="utf-8"?>'; soapXml+='<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'; soapXml+='<soap:Body>'; soapXml+='<retrieveRegardingObjectInfoOpportunity xmlns="http://tempuri.org/">'; soapXml+='<regardingObjectGuid>'+crmForm.all.regardingobjectid.DataValue[0].id+'</regardingObjectGuid>'; soapXml+='</retrieveRegardingObjectInfoOpportunity>'; soapXml+='</soap:Body>'; soapXml+='</soap:Envelope>'; var xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); xmlhttp.open("POST", serviceLocation, false); xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlhttp.setRequestHeader("Content-Length", soapXml.length); xmlhttp.setRequestHeader("SOAPAction", "http://tempuri.org/retrieveRegardingObjectInfoOpportunity"); xmlhttp.send(soapXml); // Get Values from XML Doc var xmlDocumentYo = xmlhttp.responseXML; var custIDTags = xmlDocumentYo.getElementsByTagName("rsd_currentcampaignid"); for (i=0; i < custIDTags.length; i++) { var currentcampaignGUID = xmlDocumentYo.getElementsByTagName("rsd_currentcampaignid")[i].childNodes[0].nodeValue; var currentcampaignName = xmlDocumentYo.getElementsByTagName("rsd_currentcampaignid")[i].getAttribute('name'); } //Create an array to set as the DataValue for the lookup control. var lookupDataPA = new Array(); //Create an Object add to the array. var lookupItemPA= new Object(); lookupItemPA.id = currentcampaignGUID; lookupItemPA.typename = 'Campaign'; lookupItemPA.name = currentcampaignName; // Add the object to the array. lookupDataPA[0] = lookupItemPA; crmForm.all.rsd_originatingcampaignid.DataValue = lookupDataPA; // Populate Originating Campaign END