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
juventussjuventuss 

Updating an attachment

Is there a way to replace an attachment with an updated version ?
Our company will be using sforce to share documents which are updated frequently. How would I be able to use Sforce to accomplish this task.

Thanks
DevAngelDevAngel

Hi juventuss,

Sure, you can update attachments.  There is an attachment object that contains fields like body, ownerid, parentid etc.  Just open the new document, create a byte array by reading the document, set the body field to that array and update the attachment record.  The parent Id controls which record the attachment is associated with.