CRM 2011 Export Entities Tabs and Sections Name

CRM does not provide a functionality to list all your tab and section names. With the help of SQL XML parsing feature, I managed to create an sql script to read the FormXML of the entities and parse out the tabs and sections name.

This is useful if you want to see all the tabs and sections that you have added. Enough said, this is the script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
CREATE TABLE #MyResult(
EntityName NVARCHAR(200),
Tab nvarchar(100),
Section nvarchar(100) )
 
SELECT
    RowNum = ROW_NUMBER() OVER(ORDER BY e.Name)
    , e.OriginalLocalizedName, e.ObjectTypeCode, f.FormXml
INTO #TabsAndSections
from EntityView e Left Join
  FilteredSystemForm f ON e.ObjectTypeCode = f.objecttypecode
--Filter your entity below 
--Where e.SolutionId = 'FD140AAE-4DF4-11DD-BD17-0019B9312238' AND (e.IsManaged = 0 OR e.CanModifyAdditionalSettings = 1)
AND e.OriginalLocalizedName NOT IN ('Address', 'Article', 'Lead', 'Product', 'Quote', 'SalesLiterature')
AND f.typename = 'Main' AND f.name = 'Information'
ORDER BY e.Name ASC
 
--Iterate through each entity's FormXml
DECLARE @MaxRownum int
SET @MaxRownum = (SELECT MAX(RowNum) FROM #TabsAndSections)
DECLARE @Iter int
SET @Iter = (SELECT MIN(RowNum) FROM #TabsAndSections)
WHILE @Iter <= @MaxRownum
BEGIN
 DECLARE @entityName NVARCHAR(200)
 DECLARE @t NVARCHAR(MAX)
 DECLARE @x XML
 DECLARE @idoc int
 
 SET @entityName = (SELECT OriginalLocalizedName from #TabsAndSections WHERE RowNum = @Iter)
 SET @t = (SELECT FormXml from #TabsAndSections WHERE RowNum = @Iter)
 SET @x = (SELECT CAST(@t AS XML))
 
 --Create an internal representation of the XML document.
 EXEC sp_xml_preparedocument @idoc OUTPUT, @x
 
 INSERT INTO #MyResult
 SELECT @entityName AS entityName, *
 FROM   OPENXML (@idoc, '//sections/section',2)
    WITH (Tab         nvarchar(100)         '../../../../@name',
       Section    nvarchar(100)   '@name')   
        
    SET @Iter = @Iter + 1
END
 
SELECT * FROM #MyResult
--Filter your tab and section results below
--WHERE Tab IS NOT NULL AND Section IS NOT NULL
ORDER BY EntityName ASC
 
DROP TABLE #TabsAndSections
DROP TABLE #MyResult


Hope this helps,
Andreas

Comments

Popular posts from this blog

SharePoint 2013 anonymous access add attachments to list item

CRM Plugin - Parent and Child Pipeline