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

Update Static resource from Apex



Is it possible to update a Staticresource record using the apex controller ?



Deepak Kumar ShyoranDeepak Kumar Shyoran

Hi ManjuNath,


Howeever I never used this approach but you may modify the static resource by using the apex controller becaus the web services documentation states that StaticResource can have DML operations (and indeed, it can) and if they then you can perform the dml opration on static resource.Here is a small snippet that will help you.


StaticResource sr = new StaticResource(); = 'MyStaticName';
sr.body = Blob.valueOf(myTextContent);
sr.contenttype = 'text/plain';
insert sr;


Don't forget to give Kudos if this post helped you.

Mark my answer as a solution to your question if it solve your problem.



Best Regards,

Choudhary Deepak Shyoran

Salesforce Developer






I want to update not to insert.


Thanks for the reply.



Prashant WayalPrashant Wayal


You can't do DML operations on StaticResource object from Apex. 

Please see below link:



Jordan Johnson 19Jordan Johnson 19

Thanks for sharing this informative and amazing post here. I found it very interesting and enjoy reading this blog. Will wait for more posts.

necklace box packaging (

Anand kurubaAnand kuruba
You can't do DML operations on StaticResource object from Apex
please followthe link:

The TechieThe Techie
Not possible as of now
jesszi12 joejesszi12 joe
Great Post! Thank you for visiting here.