Friday, June 25, 2010

Set the account lookup when new contact is created from the Contact lookup new button in Account form in MS CRM 4.0

function getAccountLookup()
var stringXml = window.opener.document.getElementById("fetchxml").value;

xmlDoc=new ActiveXObject("Microsoft.XMLDOM");

var name = xmlDoc.selectNodes('fetch/entity/filter/condition')[1].attributes[2].value;
var id = xmlDoc.selectNodes('fetch/entity/filter/condition')[1].attributes[4].value;

//Create an array to set as the DataValue for the lookup control.
var lookupData = new Array();

//Create an Object add to the array.
var lookupItem= new Object();

//Set the id, typename, and name properties to the object. = id;
lookupItem.typename = 'account'; = name;

// Add the object to the array.
lookupData[0] = lookupItem;

// Set the value of the lookup field to the value of the array.
crmForm.all.parentcustomerid.DataValue = lookupData;

catch (e)

No comments: