cancel
Showing results for 
Search instead for 
Did you mean: 

Reporting Dashboards Macro for Current User ID Example?

Mike_Maxson
Star Contributor
Star Contributor

Hi All,

Do you have a example of a Reporting Dashboards macro to pass the Current User ID?  I'm trying to convert the following custom SQL query for Document Types viewed by the current user and cannot get Reporting Dashboards to pass the Current User ID.  I've tried use the ##OB_CURRENTUSER_ID and the ##OB_CURRENTUSER_NAME Macro to work.  It's probably my syntax.

SQL QUERY
-------------------

SELECT d.itemtypename AS "Document Type", i.batchnum AS "Batch #", tx.logdate AS "Date", LTRIM(RIGHT(convert(varchar, tx.logdate, 100),7)) AS "Time", tx.tmessage AS "Message"FROM hsi.transactionxlog AS tx INNER JOINhsi.itemdata AS i ON tx.num = i.itemnum INNER JOINhsi.doctype AS d ON i.itemtypenum = d.itemtypenumWHERE (tx.usernum = @LoggedUserNum) AND(tx.logdate BETWEEN @DateRangeFromDate AND @DateRangeToDate) AND(tx.actionnum = 4 AND tx.subactionnum = 1)ORDER BY tx.logdate

Much appreciated,

Mike

2 REPLIES 2

Larissa_Armand
Elite Collaborator
Elite Collaborator

Hi Mike,

Here's what I use: 

select distinct T.ITEMNUM, rtrim(D.ITEMTYPENAME), rtrim(I.ITEMNAME), max(T.LOGDATE),	case when I.STATUS = '16' then 'Deleted' else NULL end as DocumentStatusfrom TRANSACTIONXLOG T, ITEMDATA I, DOCTYPE Dwhere T.ITEMNUM = I.ITEMNUM and I.ITEMTYPENUM = D.ITEMTYPENUM    and T.ACTION = '32'    and T.USERNUM = ##OB_CURRENTUSER_ID    and T.LOGDATE >= sysdate -30group by T.ITEMNUM, D.ITEMTYPENAME, I.ITEMNAME, case when I.STATUS = '16' then 'Deleted' else NULL endorder by max(T.LOGDATE) desc ;

Mike_Maxson
Star Contributor
Star Contributor

Thanks so much Larissa