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
ManjunathManjunath 

Update Static resource from Apex

Hi,

 

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

 

Regards,

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();
sr.name = '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

 

 

ManjunathManjunath

Hi,

 

I want to update not to insert.

 

Thanks for the reply.

 

Regards,

Prashant WayalPrashant Wayal

Hi,

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

Please see below link:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_non_dml_objects.htm

 

Thanks.

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 (https://huijupackaging.com/product/earring-box-jewelry-box/)

Anand kurubaAnand kuruba
Hi,
You can't do DML operations on StaticResource object from Apex
please followthe link:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dev_guide.htm

https://trailhead.salesforce.com/content/learn/modules/visualforce_fundamentals/visualforce_static_resources


Thanks!!
 
The TechieThe Techie
Not possible as of now
jesszi12 joejesszi12 joe
Great Post! Thank you for visiting here. https://nextgen-patientportal.com/