+ 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.