You need to sign in to do that
Don't have an account?
dillip nayak 3
How to Get Content Type Using Name Attchment object.Is there any method to get content type
How to Get Content Type if content type is blank in attchment object.Is there any method that help to get content type with using Name Field of attchment object.
Thanks
Thanks
if you are using Visualforce you can use something like this:
After the postback you have the 3 variables set and ready to be used.
(https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_inputFile.htm)
--
May The Force.com be with you!
@enreeco
Thanks for your message .I need it on trigger
trigger AttchmentContentType on Attachment (After Insert) {
if(trigger.isinsert && trigger.isafter)
{
list<Attachment> attchmentList=new list<Attachment>();
for(Attachment attachment:[select id,name,ContentType from Attachment where id=:trigger.newMap.keySet()])
{
if(string.isBlank(attachment.ContentType) || string.isEmpty(attachment.ContentType)) {
if(attachment.Name.endsWith('.txt'))
attachment.ContentType='text/plain';
else if(attachment.Name.endsWith('.csv'))
attachment.ContentType='application/vnd.ms-excel';
else if(attachment.Name.endsWith('.doc'))
attachment.ContentType='application/msword';
attchmentList.add(attachment);
} }
if (attchmentList.size()>0) update attchmentList;
} }
i Dont wan to use endswith because some time user rename the file.
i need it dynamically is there any method.please share me the code.if you have
Look forward to hear from you.
Thanks