第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何忽略 CRM 查找字段中的 NULL 值?

如何忽略 CRM 查找字段中的 NULL 值?

慕斯709654 2021-10-21 14:02:25
我有以下代碼設(shè)置 onLoad 以在關(guān)聯(lián)帳戶標(biāo)記為“服務(wù)監(jiān)視”時在“發(fā)貨”記錄上生成橫幅。該代碼當(dāng)前可以運行,但它會生成錯誤警報"unable to get property '0' of undefined or null reference"。當(dāng)用戶創(chuàng)建新的貨件記錄時會發(fā)生此錯誤,因為帳戶字段尚無值。如何配置代碼以忽略帳戶字段中的 NULL 值?function checkServiceWatch() {    try{        var account = Xrm.Page.getAttribute("cmm_account").getValue();        var accountid = account[0].id;        var formattedGuid = accountid.replace("}", "");        accountid = formattedGuid.replace("{", "");        // alert("Accountid: " + accountid);  // does that ID have brackets around it?        // alert("Request: " + Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts(" + accountid + ")?$select=cmm_servicewatch");        var req = new XMLHttpRequest();        req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts(" + accountid + ")?$select=cmm_servicewatch", true);        req.setRequestHeader("OData-MaxVersion", "4.0");        req.setRequestHeader("OData-Version", "4.0");        req.setRequestHeader("Accept", "application/json");        req.setRequestHeader("Content-Type", "application/json; charset=utf-8");        req.onreadystatechange = function()應(yīng)忽略正在創(chuàng)建的記錄,但會在具有帳戶值的現(xiàn)有貨件上生成橫幅。
查看完整描述

3 回答

?
汪汪一只貓

TA貢獻(xiàn)1898條經(jīng)驗 獲得超8個贊

您必須檢查帳戶變量是否已正確初始化。如果有,返回該變量將等同于true,如果它不存在,它將返回false并且不運行該部分中的其余代碼try。正確的代碼如下:


function checkServiceWatch() {

    try{

        var account = Xrm.Page.getAttribute("cmm_account").getValue();

        if(account) {

        var accountid = account[0].id;

        var formattedGuid = accountid.replace("}", "");

        accountid = formattedGuid.replace("{", "");

        // alert("Accountid: " + accountid);  // does that ID have brackets around it?

        // alert("Request: " + Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts(" + accountid + ")?$select=cmm_servicewatch");


        var req = new XMLHttpRequest();

        req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts(" + accountid + ")?$select=cmm_servicewatch", true);

        req.setRequestHeader("OData-MaxVersion", "4.0");

        req.setRequestHeader("OData-Version", "4.0");

        req.setRequestHeader("Accept", "application/json");

        req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

        req.onreadystatechange = function()

        {

            if (this.readyState === 4) 

            {

                req.onreadystatechange = null;

                if (this.status === 200) 

                {

                    var result = JSON.parse(this.response);

                    var serviceWatch = result["cmm_servicewatch"];

                    // alert("serviceWatch: " + serviceWatch);

                    if(serviceWatch) //set notification

                    {

                        Xrm.Page.ui.setFormNotification("This Account is currently under Service Watch","WARNING","1");     

                    } // else 

                    // {

                    //   //Xrm.Page.ui.clearFormNotification("1");

                    // }  

                } 

                else 

                {

                    Xrm.Utility.alertDialog("Status: " + this.status + ", Text: " + this.statusText);

                }

            }

        };

        req.send();

    }

    }

    catch (err) {

        alert("ServiceWatchCheckRibbon | checkServiceWatch " + err.message);

    }   

}


查看完整回答
反對 回復(fù) 2021-10-21
  • 3 回答
  • 0 關(guān)注
  • 199 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號