CRM 2013 - JavaScript 识别约会的父实体类型(客户或联系人)

CRM 2013 - JavaScript to identify parent entity type on Appointments (Account or Contact)

CRM 2013 customizer/developer 在这里。我是 JavaScript 的新手,我需要一些关于可在 CRM 2013 的 OnLoad 事件中使用的查询的帮助。

在 'Appointments' 实体上,我需要根据其相关父记录('regardingobjectid')的实体类型设置自定义字段(选项集)的值。

示例;

-如果 'regardingobjectid' 实体类型 = 'Account' 则将 "custom field" 的值设置为 "x",

-如果 'regardingobjectid' 实体类型 = 'Contact' 则将 "custom field" 的值设置为 "y"。

自定义字段是一个选项集,有 3 个可能的值 (x,y,z) 所以如果可以隐藏值 "z" 当 'regardingobjectid' 实体类型 = 'Contact' 时会很棒。任何帮助将不胜感激。

Appointment 个实体的 OnLoad 添加新功能。

function onLoadOfAppointment() {
if (Xrm.Page.ui.getFormType() == 2) {

    var regardingObject = Xrm.Page.getAttribute("regardingobjectid");
    if (regardingObject != null && regardingObject.getValue() != null)
    {
        var entityType = regardingObject.getValue()[0].entityType;
        if (entityType == "account")
        {
            //Add account logic here
        }
        else if (entityType == "contact")
        {
            //Add contact logic here
        }
    }
}
}

隐藏显示 OptionSet 值。关注以下网址:

dynamically-change-option-set-values-in-crm

Add new Picklist Option using Javascript

Xrm.Page.ui control (client-side reference)