cancel
Showing results for 
Search instead for 
Did you mean: 

How do you get a list of all document groups?

Curtis_Stodgell
Champ in-the-making
Champ in-the-making

Hi there,

I want to get a list of all document groups names and then a list of all document type names.  I can't figure it out looking at the documentation.  

I don't want any particular document, just their associated type name.

THanks!

3 REPLIES 3

Dean_Johnson
Star Collaborator
Star Collaborator

Depending on the size of your Database this might take a couple minutes to run.

SELECT 	CASE WHEN itg.itemtypegroupname IS NULL THEN  		CASE WHEN dt.itemtypename IS NULL THEN '-- Grand Document Total' END 	ELSE itg.itemtypegroupname -- Document Type Group Total 	END as 'Document Type Group Name', 	CASE WHEN dt.itemtypename IS NULL THEN  		CASE WHEN itg.itemtypegroupname IS NULL THEN '-- Document Type Document Grand Total'  		ELSE '-- Document Type Group Total' 		END 	ELSE dt.itemtypename -- Document Type Total 	END as 'Document Type Name', 	COUNT(id.itemnum) as 'Document Type Page Count'	 FROM hsi.itemdata id JOIN hsi.doctype dt ON dt.itemtypenum = id.itemtypenum JOIN hsi.itemtypegroup itg ON itg.itemtypegroupnum = id.itemtypegroupnum GROUP BY itg.itemtypegroupname, dt.itemtypename with ROLLUP ORDER BY itg.itemtypegroupname ASC

Steve_Warner
Star Contributor
Star Contributor

Slimmed down SQL script if you only want the DocTypeGroups and the DocTypes:

/*
Select DocTypeGroup and DocType
*/
SELECT RTRIM(itemtypegroupname) AS DocTypeGroup, RTRIM(itemtypename) AS DocType
FROM hsi.doctype AS DT
JOIN hsi.itemtypegroup AS DTG ON DT.itemtypegroupnum = DTG.itemtypegroupnum
ORDER BY itemtypegroupname, itemtypename

 

Alex_French
Elite Collaborator
Elite Collaborator

Are you looking for a SQL query, or using the Unity API?

Dean's query includes counts of documents, but just getting lists of Document Type Group names and Document Type Names can be much simpler.