0

Below is an image highlighting the information that I would like to retrieve programmatically using Apex (would also like to retrieve report last run date). I can see all the relevant information that I need on the workbench, but I want to retrieve that programmatically for select reports and use them in my code. Any help is appreciated. Thanks.

enter image description here

2
  • 2
    What about soql query like [SELECT Id, Name, CreatedDate, CreatedBy.Id, CreatedBy.Name, LastModifiedDate, LastModifiedBy.Name from Report]?
    – kurunve
    Feb 3, 2022 at 15:22
  • @kurunve Yep, that's how you'd do it, and you should turn that into an answer.
    – Derek F
    Feb 3, 2022 at 15:50

1 Answer 1

2

Reports are available to be queried via SOQL. Therefore following query would work:

SELECT Id, Name, CreatedDate, CreatedBy.Id, CreatedBy.Name, LastModifiedBy.Name 
FROM Report

More information about available fields can be found here.

4
  • Thanks for the answer. But since the LastModifiedBy.Name only gives the Id, is there any way I can get the name of the user instead of just their Id?
    – apexdev
    Feb 4, 2022 at 16:23
  • LastModifiedBy.Name returns name of the user (first name + last name).
    – kurunve
    Feb 4, 2022 at 16:24
  • That's odd, because when I run this query I get this LastModifiedById=0055f000003C... as the result for LastModifiedBy.Name . I'm only getting the Id and not the first and last name like I should.
    – apexdev
    Feb 4, 2022 at 16:29
  • Well, it works fine (imgur.com/a/5JnwVzx) . Probably something specific for your query client
    – kurunve
    Feb 4, 2022 at 16:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .