Set a lookup value in CRM 2011

// Sets the lookup value for a certain field
function SetLookupValue(fieldName, id, name, entityType) 
{
	if(fieldName != null) 
	{
		var lookupValue = new Array();
		lookupValue[0] = new Object();
		lookupValue[0].id = id;
		lookupValue[0].name = name;
		lookupValue[0].entityType = entityType;

		Xrm.Page.getAttribute(fieldName).setValue(lookupValue);
	}
}

Leave a comment

Your email address will not be published. Required fields are marked *