码迷,mamicode.com
首页 > 编程语言 > 详细

Js 案例,排序和比较

时间:2021-06-03 17:59:51      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:ESS   message   null   reac   name   oci   status   sage   error   

通过某一个值排序输出

 if (json.Entity[0].Attributes.find(f => f.Key == "ssss_confirmed_by") != undefined) {
                SDK.CrmRest.retrieveMultipleRecords("SystemUser", "?$select=teammembership_association/Name,teammembership_association/ssss_rank,teammembership_association/TeamId&$expand=teammembership_association&$filter=SystemUserId eq (guid‘" + json.Entity[0].Attributes.find(f => f.Key == "ssss_confirmed_by").Value.Id + "‘)", function (results) { 
                    confirmteam = getSystemUserTeam(results[0].teammembership_association);        
                }, function (error) {
                    Xrm.Utility.alertDialog(error.message);
                }, function () {
                    //On Complete - Do Something
                });
            }

 

function getSystemUserTeam(object) {
            var list = object;
            if (list.results.length == 1) {
                return list.results[0].Name;
            }
            else if (list.results.length > 1) {
                let srr = list.results;
                srr.forEach((item, index, srr) => {
                    //null remove
                    if (item.ssss_rank === null) {
                        srr.splice(index, 1)
                    }
                });
                //排序
                list.results.sort(function (a, b) {
                    return a.ssss_rank - b.ssss_rank
                })
                return  list.results[0].Name;
            }
        }

比较,是否包含数值

//隐藏sub-gridd[+]按钮
function ShowRoleForBaidu_Potential() {
    return fnHiddenSubGridButton("crms_potential_casse_status", [722890003, 722890004, 722890005], false);
}
function fnHiddenSubGridButton(FieldName, OptionValues, InvertResult) {
    var ret = true;
    if (Xrm.Page.getAttribute(FieldName) != null) {
        var FieldValue = Xrm.Page.getAttribute(FieldName).getValue();
        if (OptionValues.indexOf(FieldValue) == -1) ret = true;
        else ret = false;
    }
    if (InvertResult) ret = !ret;
    return ret;
}

 

Js 案例,排序和比较

标签:ESS   message   null   reac   name   oci   status   sage   error   

原文地址:https://www.cnblogs.com/shanshuiYiCheng/p/14844070.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!