Friday, March 9, 2012

expression to get CreatedBy, CreationDate, ModifiedBy, and ModifiedDate properties for report?

If you look at the General Properties for a report in Report Manager, there are 4 properties listed at the top:

Modified Date: 2/26/2007 6:37 PM Modified By: DOMAIN\username1 Creation Date: 2/14/2006 5:19 PM Created By: DOMAIN\username2

What I'm looking for is if there's a way to retrieve these properties via an expression from a textbox within a report. For instance, there's already an expression that is:

=Globals!ReportName

I know it won't be that easy for the CreatedBy, CreationDate, ModifiedBy, and ModifiedDate properties, but I thought I'd ask if there was a workaround or hack.

We're wanting to put that info into the footer of all our reports. (Actually this is for Report Builder reports, but you can still use expressions in Report Builder reports, so it should apply as it would to normal reports.)

Hi Greg,

I don't believe any of that information is stored in the RDL itself. The only way I know to get that information is to query the ReportServer database, similar to:

SELECT [ModifiedDate]

,[Modified].[UserName]

,[CreationDate]

,[Created].[UserName]

FROM [ReportServer].[dbo].[Catalog]

INNERJOIN [ReportServer].[dbo].[Users] as [Modified] ON [Catalog].[ModifiedByID] = [Modified].[UserID]

INNERJOIN [ReportServer].[dbo].[Users] as [Created] ON [Catalog].[CreatedByID] = [Created].[UserID]

WHERE [Catalog].Name =Globals!ReportName.Value

Then you can access those fields from the dataset.

HTH,

Jessica

No comments:

Post a Comment