0

I am trying to retrieve All the Javascript events/libraries attached to the form of particular entity from the server side.

I am able to retrieve the all the forms of that particular entity by using query expression

 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);

I just need to know the Javascript library attached to OnLoad or OnSave Events in CRM form.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

2 Answers2

2

Querying the formxml attribute on the form will give you what you are looking for. For e.g. to get all the attribute, event and function names on contact form:

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")
                        });
dynamicallyCRM
  • 2,980
  • 11
  • 16
0

Just FYI. systemform object doesn't contain entity forms. It contains dashboards - https://msdn.microsoft.com/en-us/library/gg334669.aspx

To get what you need you will have to get entity metadata that will contain forms. Description of a form is an Xml that contains what you need.

Andrew Butenko
  • 5,048
  • 1
  • 14
  • 13