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
V AnandV Anand 

Giving version numbers to new attachments

Hi...

 

I have to create a attachment programmatically, there is create button on accounts when user clicks on that button one attachment will be created.

 

I have done above perfectly .. but problem is have to maintain version numbers of newly created attachment . like below

 

each button click

Attachment_V1

Attachment_V2

Attachment_V3 ........

 

like quote  PDF ganeration on opportunity...

How will I maintain version numbers programatically.....

Any help appriciated.....

 

 

 

ForcepowerForcepower

You can query the Attachment object to get the latest attachment with this account as parent id. Then parse the name of that attachment and get the suffix number after the underscore. Increment it and use it for the new attachment.

best,

Ram

V AnandV Anand
Thanks for reply ... I have already tried what you said , here the problem is as per your idea incrementing the number is working for same extend. It means If I open the record click the button then attachment created as
AttachmentV1
again click the button
AttachmentV2
once I close the record and again open it then click the button It will created from again 1 like below
AttachmentV1
AttachmentV2
Its not maintaining the previous count.
ForcepowerForcepower
Can you post the query and code you're using to get the latest attachment and how you formulate the next one?
V AnandV Anand
Thanks a lot .... I have finally resolved it.