Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

Populating Service Activity Fields in 4.0

$
0
0
Need help. Below is the code. We creating a new entity in our 4.0 environment and when we create a Service Activity off of it we need a field called Primary Account populated. With the code below it populates a new account but doesn't pull in the account listed on the project. 

//------------------------------------------------------- // -- Populate Appointment Fields - Project //------------------------------------------------------- if (regardingType == 'new_project') // Regarding is an Project { // Populate Primary Account ------------------------------------------------------------ var serviceLocation = prependOrgName("/ISV/CRMServices/CrmRetrievalServiceIndustry.asmx"); var soapXml='<?xml version="1.0" encoding="utf-8"?>'; soapXml+='<soap:Envelope xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns:soap="schemas.xmlsoap.org/.../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", "tempuri.org/retrieveRegardingObjectInfoOpportunity"); xmlhttp.send(soapXml); // Get Values from XML Doc var xmlDocumentYo = xmlhttp.responseXML; var custIDTags = xmlDocumentYo.getElementsByTagName("new_accountid"); for (i=0; i < custIDTags.length; i++) { var primaryAccountGUID = xmlDocumentYo.getElementsByTagName("new_accountid")[i].childNodes[0].nodeValue; var primaryAccountName = xmlDocumentYo.getElementsByTagName("new_accountid")[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 = primaryAccountGUID; lookupItemPA.typename = 'account'; lookupItemPA.name = primaryAccountName; // Add the object to the array. lookupDataPA[0] = lookupItemPA; crmForm.all.rsd_primaryaccountid.DataValue = lookupDataPA; // Resources (Owner of the Account) var xmlDocumentYo = xmlhttp.responseXML; var custIDTags = xmlDocumentYo.getElementsByTagName("ownerid"); for (i=0; i < custIDTags.length; i++) { var OwnerGUID = xmlDocumentYo.getElementsByTagName("ownerid")[i].childNodes[0].nodeValue; var OwnerName = xmlDocumentYo.getElementsByTagName("ownerid")[i].getAttribute('name'); } //Create an array to set as the DataValue for the lookup control. var lookupDataOwner = new Array(); //Create an Object add to the array. var lookupItemOwner= new Object(); lookupItemOwner.id = OwnerGUID; lookupItemOwner.typename = 'systemuser'; lookupItemOwner.name = OwnerName; // Add the object to the array. lookupDataOwner[0] = lookupItemOwner; //crmForm.all.resources.DataValue = lookupDataOwner; crmForm.all.resources.DataValue = crmForm.all.ownerid.DataValue; // Populate Primary Account END ---------------------------------------------------------- } //------------------------------------------------------- // -- Populate Appointment Fields - Project END //-------------------------------------------------------

Viewing all articles
Browse latest Browse all 55831

Trending Articles