CRM JS 设置lookup字段 setSimpleLookupValue

Posted BinBinGo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CRM JS 设置lookup字段 setSimpleLookupValue相关的知识,希望对你有一定的参考价值。

function setSimpleLookupValue(LookupId, Type, Id, Name) {
    /// <summary>
    /// Sets the value for lookup attributes that accept only a single entity reference.
    /// Use of this function to set lookups that allow for multiple references, 
    /// a.k.a ‘partylist‘ lookups, will 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 be displayed in the lookup.
    /// </param>
    ///setSimpleLookupValue("primarycontactid", "contact", "{6D9D4FCF-F4D3-E011-9D26-00155DBA3819}", "Brian Lamee");


    var lookupReference = [];
    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 设置lookup字段 setSimpleLookupValue的主要内容,如果未能解决你的问题,请参考以下文章

在Dynamics 365的标准窗体,lookup字段变成了[Object Object],picklist直接展示数字

Dynamics CRM2016 Web API之获取查找字段的text及选项集的text

CRM 2016 自定义lookup过滤

CRM 2016 子表单中N:1关系 字段要求与新建时的关系

Mongoose:$lookup 后的 $project 不显示字段

JavaScript 设置SharePoint Lookup字段的值