function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Change Reports OwnerId through code

Does anyone know how to change the Reports OwnerId through code?  I get the error, Field is not writeable: Report.OwnerId.


Basically the reason for this is that i'm doing a query to return Reports and if they are returned I want to place them in a specific folder.


List<Report> temp = [SELECT name, LastRunDate FROM Report WHERE LastRunDate >=: ( - 90)];

for (Report curr: temp)     

    curr.OwnerId =;

upsert temp;


You can't change the OwnerId of that Report through Apex.


If you want to want to change a folder's report, try looking at the Folder sObject, though I'm not sure how it works.


It's possible that you can't programmatically change the folder of a report. Does anyone else know if this is possible?