1) Get the list of table with audit enabled -
SELECT logicalname, displayname, isauditenabledFROM metadata.entityWHERE isauditenabled = 1ORDER BY logicalname;2) Get the list of fields per table with audit enabled -
SELECT entitylogicalname, logicalname AS columnname, displayname, isauditenabledFROM metadata.attributeWHERE isauditenabled = 1 AND entitylogicalname IN (SELECT logicalname FROM metadata.entity WHERE isauditenabled = 1)ORDER BY entitylogicalname, columnname;
3) Get the total number of activity records by different activity type -
SELECT activitytypecodename, activitytypecode, Count(activitytypecode) AS TotalFROM activitypointerGROUP BY activitytypecode, activitytypecodenameORDER BY Total DESC;
4) Get the Time Zone information of all the users -
SELECT su.fullname, su.domainname, us.timezonecode, tz.userinterfacename, tz.standardnameFROM usersettings AS us INNER JOIN systemuser AS su ON us.systemuserid = su.systemuserid LEFT OUTER JOIN timezonedefinition AS tz ON us.timezonecode = tz.timezonecodeORDER BY su.fullname;
5) Get the list of cloud flows where a specific field is referred / used -
SELECT wf.name, wf.workflowid, wf.clientdataFROM workflow AS wfWHERE wf.category = 5 AND LOWER(wf.clientdata) LIKE '%columnName%';
6) Get the list of Business Rules in the environment -
SELECT primaryentity, primaryentityname, workflowid, workflow.name AS BusinessRuleName, workflow.ismanaged, statecode, statecodename, categorynameFROM workflow INNER JOIN entity ON workflow.primaryentity = entity.objecttypecodeWHERE category = 2ORDER BY primaryentity;
7) Get the list of Plugin Registration Steps where a particular attribute is used in the Image -
SELECT spi.sdkmessageprocessingstepimageid, s.name AS StepName, spi.name AS ImageName, spi.imagetype, spi.attributes, s.name AS StepName, m.name AS MessageName, e.name AS EntityNameFROM sdkmessageprocessingstepimage spiINNER JOIN sdkmessageprocessingstep s ON spi.sdkmessageprocessingstepid = s.sdkmessageprocessingstepidINNER JOIN sdkmessagefilter f ON s.sdkmessagefilterid = f.sdkmessagefilteridINNER JOIN sdkmessage m ON f.sdkmessageid = m.sdkmessageidINNER JOIN entity e ON f.primaryobjecttypecode = e.objecttypecodeWHERE spi.attributes LIKE '%columnName%'ORDER BY EntityName, MessageName
8) Get the list of Security Role and total number of users assigned that role -
SELECT r.name AS RoleName, COUNT(DISTINCT sur.systemuserid) AS AssignedUsersFROM systemuserroles AS sur INNER JOIN role AS r ON sur.roleid = r.roleidGROUP BY r.nameORDER BY AssignedUsers DESC;
9) Get number of security roles assigned per user -
SELECT u.systemuserid, u.fullname, COUNT(sur.roleid) AS RoleCountFROM systemuser AS u INNER JOIN systemuserroles AS sur ON u.systemuserid = sur.systemuseridGROUP BY u.systemuserid, u.fullnameORDER BY RoleCount DESC;
10 ) Get the list of security roles assigned to a particular user -
SELECT su.systemuserid, su.fullname AS UserName, r.roleid, r.name AS RoleName, r.businessunitidname AS BusinessUnitFROM systemuser suINNER JOIN systemuserroles sur ON su.systemuserid = sur.systemuseridINNER JOIN role r ON sur.roleid = r.roleidwhere sur.systemuserid = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
11) Get the list of users and security roles assigned to them-
SELECT u.systemuserid, u.fullname AS UserName, u.domainname AS UserDomain, u.isdisabled AS IsDisabled, u.businessunitidname AS BusinessUnit, STRING_AGG(r.name, ', ') AS SecurityRoles FROM systemuser uINNER JOIN systemuserroles ur ON u.systemuserid = ur.systemuseridINNER JOIN role r ON ur.roleid = r.roleidWHERE u.isdisabled = 0 AND u.accessmode = 0 -- Only interactive users AND u.domainname NOT LIKE '#%' -- Exclude system/app usersGROUP BY u.systemuserid, u.fullname, u.domainname, u.isdisabled, u.businessunitidname, u.accessmodeORDER BY u.fullname;
