如何检索附加到CRM 2016服务器端表单的Javascript事件的名称

How to retrieve name of Javascript events attached to form in CRM 2016 server side

本文关键字:表单 2016 服务器端 Javascript 事件 CRM 何检索 检索      更新时间:2023-09-26

我试图从服务器端检索附加到特定实体形式的所有Javascript事件/库。

我能够通过使用查询表达式

检索特定实体的所有形式
 QueryExpression q = new QueryExpression("systemform");
            q.ColumnSet = new ColumnSet() { AllColumns = true };
            q.Criteria.AddCondition(new ConditionExpression("objecttypecode", ConditionOperator.Equal, "account"));
            EntityCollection ec = serviceProxy.RetrieveMultiple(q);

我只需要知道的Javascript库附加到OnLoad或OnSave事件在CRM的形式。

查询表单上的formxml属性将为您提供您正在寻找的内容。例如,获取联系人表单上的所有属性、事件和函数名:

var attributeEventsDetails =
                XDocument.Parse(xrmServiceContext.SystemFormSet.FirstOrDefault(form => form.Name == "contact").FormXml)
                    .Descendants("event")
                    .Select(descendants =>
                        new
                        {
                            AttributeName = descendants.Attribute("attribute"),
                            EventName = descendants.Attribute("name"),
                            FunctionName =
                                descendants.Descendants()
                                    .FirstOrDefault(childDesc => childDesc.Name == "Handler")
                                    .Attribute("functionName")
                        });

仅供参考。Systemform对象不包含实体表单。它包含仪表板- https://msdn.microsoft.com/en-us/library/gg334669.aspx

要得到你需要的东西,你必须得到包含表单的实体元数据。表单的描述是包含所需内容的Xml。