In previous posts I describe some common functions I use to get field text values, set optionset values from text, set text field values etc. Here is another post containing a standard functions to set lookup values;
// *** FUNCTION: SetLookUp // *** PARAMS: // *** fieldName = The name of the lookup field // *** fieldType = The type of field (contact, account etc) // *** fieldId = The ID of the value to set (GUID) // *** value = the value(name) to set function SetLookUp(fieldName, fieldType, fieldId, value) { try { var object = new Array(); object[0] = new Object(); object[0].id = fieldId; object[0].name = value; object[0].entityType = fieldType; Xrm.Page.getAttribute(fieldName).setValue(object); } catch (e) { alert("Error in SetLookUp: fieldName = " + fieldName + " fieldType = " + fieldType + " fieldId = " + fieldId + " value = " + value + " error = " + e); } }