zoukankan      html  css  js  c++  java
  • Js 案例,排序和比较

    通过某一个值排序输出

     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;
    }
  • 相关阅读:
    JavaScript 深入了解对象中的属性
    JavaScript 开发规范
    vue 项目接口管理
    放大镜特效
    多用户ATM机(面向对象编程)
    浏览器检查块代码
    js中innerHTML与innerText的用法与区别
    symbol访问法及symbor注册表
    最常用的15个前端表单验证JS正则表达式
    数组的遍历
  • 原文地址:https://www.cnblogs.com/shanshuiYiCheng/p/14844070.html
Copyright © 2011-2022 走看看