创建dynamics CRM client-side (九) - 用JS来获取look up 信息

我们用以下的代码可以获取到look up 的信息。

 

大家可以查看微软文档来查看更多关于 lookup object的信息

https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-utility/lookupobjects

 

我们可以使用 下面代码来展示信息:

formContext.ui.setFormNotification("Guid of the Account: " + accountGuid, "Info", "notification1");

 

// Converting functions to Namespace Notation
var Sdk = window.Sdk || {};
(
    function () {
        this.formOnLoad = function (executionContext) {
            var formContext = executionContext.getFormContext();
            //var firstName = formContext.getAttribute("firstname").getValue();
            //alert("Hello World " + firstName);

            var lookupAccountArray = formContext.getAttribute("parentcustomerid").getValue();

            if (lookupAccountArray !== null && lookupAccountArray[0] != null) {
                // you will get entity type, name and id
                var accountGuid = lookupAccountArray[0].id;
                var accountName = lookupAccountArray[0].name;
                var accountType = lookupAccountArray[0].entityType;

                formContext.ui.setFormNotification("Guid of the Account: " + accountGuid, "Info", "notification1");
                formContext.ui.setFormNotification("Name of the Account: " + accountName, "Info", "notification2");
                formContext.ui.setFormNotification("Type of the Account: " + accountType, "Info", "notification3");
            }
        };
    }
).call(Sdk);

 

 

创建dynamics CRM client-side (九) - 用JS来获取look up 信息

posted @ 2019-07-09 10:38  TheMiao  阅读(543)  评论(0编辑  收藏  举报