Thursday, October 5, 2017

Get Current User running report list in Ax 2012 from SQL DB

--Query

SELECT UserInfo.[Name],
ElementName AS [Report Name],
UserInfo.[Enable] AS [Active Employee]
INTO #temp
FROM SysLastValue WITH(NOLOCK)
INNER JOIN UserInfo WITH(NOLOCK)
                ON UserInfo.ID = SysLastValue.UserID
WHERE UserID NOT IN ('Admin', '')
     AND RecordType = 18 /* Report */



SELECT t.[Report Name],
(SELECT COUNT(DISTINCT [Name])
   FROM #temp sub
WHERE sub.[Active Employee] = 1
AND sub.[End User] = 1
AND sub.[Report Name] = t.[Report Name]) AS [# of Active Employees Who Ran The Report]
FROM #temp t
GROUP BY t.[Report Name]
ORDER BY t.[Report Name]

DROP TABLE #temp

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...