+ 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 >=: (System.today() - 90)];

for (Report curr: temp)     

    curr.OwnerId = myfolder.id;

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?