如何列出控制台中所有脏的CRM字段? [英] How to list all CRM fields which are dirty in console?

查看:109
本文介绍了如何列出控制台中所有脏的CRM字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种方法来获取CRM表单中所有脏字段的列表,以确定更改的内容和需要保存在浏览器控制台中的内容.一般而言,这将有助于我调试javascript或其他与CRM相关的问题

I have been looking for a way to get the list of all dirty fields in the CRM form to determine the what was changed and need to be saved in the browser console. This will help me debugging the javascript or other CRM related issues in general

我该如何实现?

推荐答案

您可以使用以下代码作为参考

You can use the following code for your reference

var attribs = Xrm.Page.data.entity.attributes.get();

从中获取所有字段的列表,然后以

to get the list of all fields in the from and then call the function getIsDirty() for it as

var filterDirty = attribs.filter(function(elem,index,attribs){   
        var name =  elem.getName();
        return (Xrm.Page.getAttribute(name).getIsDirty() === true);
});

现在filterDirty将保存所有脏字段的数组,您可以将其与地图一起打印为

Now the filterDirty will hold an array of all the dirty fields and you can just print it with the map as

filterDirty.map(function(e){ console.log(e.getName()); });

注意:只需确保Xrm可用,您就可以看到为什么我在上述

Note: Just make sure Xrm is available you can see why there is additional bit of code before the what i described above from here

整个代码对您来说将是这样

the whole code will look something like this for you

// get the correct frame
for(var i=0;i<5;i++) //loop through 0 to 4
    if(frames[i].Xrm.Page.ui != undefined) //check if undefined    
    {
        Xrm = frames[i].Xrm;  //assign Xrm
        console.info("~: Xrm updated with frame " + i + " :~"); //show info
        break; //breakout the loop
    }

//Query
var attribs = Xrm.Page.data.entity.attributes.get();

//Filter
var filterDirty = attribs.filter(function(elem,index,attribs){   
        var name =  elem.getName();
        return (Xrm.Page.getAttribute(name).getIsDirty() === true);
});

//print
filterDirty.map(function(e){
  console.log(e.getName()); 
});

这篇关于如何列出控制台中所有脏的CRM字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆