functionSetsimplelookupvalue (LookupId, Type, Id, Name) {///<summary> ///sets the value for lookup attributes this accept only a single entity reference. ///Use of the This function to set lookups. Allow for multiple references, ///a.k.a ' partylist ' lookups, would remove any other existing references and ///replace it with just the single reference specified. ///</summary> ///<param name= "lookupid" type= "String" maybenull= "false" Optional= "false" > ///The lookup attribute logical name ///</param> ///<param name= "Type" type= "String" maybenull= "false" Optional= "false" > ///The logical name of the entity being set. ///</param> ///<param name= "Id" type= "String" maybenull= "false" Optional= "false" > ///A string representation of the GUID value for the record being set. ///The expected format is "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}". ///</param> ///<param name= "name" type= "String" maybenull= "false" Optional= "false" > ///The text to is displayed in the lookup. ///</param> ///setsimplelookupvalue ("Primarycontactid", "contact", "{6d9d4fcf-f4d3-e011-9d26-00155dba3819}", "Brian LaMee"); varLookupreference = []; lookupreference[0] = {}; lookupreference[0].id =Id; lookupreference[0].entitytype =Type; lookupreference[0].name =Name; Xrm.Page.getAttribute (lookupid). SetValue (lookupreference); Xrm.Page.getAttribute (lookupid). Setsubmitmode ("Always");}
CRM JS Set lookup field Setsimplelookupvalue