You need to sign in to do that
Don't have an account?
Rohit K Sethi
Actually we insert the attachment under account as pdf
and once a pdf is attached with the account and next time If with same content the pdf is attached with same account then I have to prevent.
Thanks.
Can we find the duplicate attachment inserted on the bases of there body ?
Actually we insert the attachment under account as pdf
and once a pdf is attached with the account and next time If with same content the pdf is attached with same account then I have to prevent.
Thanks.
I don't think so. Easier way is to follow naming covention while uplaoding the file in salesforce or you can write trigger to create name for attachment,
Main challenge in comparing the two attachmnet is the heap size issue. Attachment size can be upto 5MB and comparing two attachment we need 5 MB + 5 MB + some variables memory. And salesforce only support 6 MB hep size in sync mode.
Hope it will help!!
Thanks for quick reply.
But My file maximum contains the (1KB-100KB) data.
So size is not matter for my problem so plz suggest the way how we will check.
Thanks.
You can try by converting the attachment body in string format and then compare the two strings. Let me know if it works for you.
Code to covert the attachment body in string is -
Attachment csvFileBody = [SELECT Id,Body, Name FROM Attachment where id = attach.Id];
Blob csvBlob = csvFileBody.Body;
String csvAsString = csvBlob.toString();
Thanks,
Ishwar
I am allready try this but its not worked.
Thanks.
I also had a doubt about it, but there was no other solution for it. I hope, it should work for text files.
Else, you need to follow the naming convention for file to identify the duplicate.
Hope it is helpful.
Thanks and Regards,
Ishwar Shinde