2 answers
HI Praveen,Lets suppose below Api namestest Object ==>test_object__cpicklist Field = pickList__cCheckbox marked = Checkbox_marked__cCheckbox Unmarked = Checkbox_Unmarked__cAnd also refer the below article how to create trigger on Attachment objecthttps://help.salesforce.com/HTViewSolution?id=000181538&language=en_USPlease check the below codetrigger testAttachment on Attachment (after insert) { Set<Id> parentId = new Set<Id>(); List<test_object__c> lstTestObjToUpdate = new List<test_object__c>(); Map<Id,test_object__c> maptestObjWIthId = new Map<Id,test_object__c>(); Set<Id> testObjProcessed = new Set<Id>(); String parentPrefix = Schema.getGlobalDescribe().get('test_object__c').getDescribe().getKeyPrefix(); for(Attachment att: trigger.new){ if(att.ParentId != null && String.valueOf(att.parentId).startsWith(parentPrefix)){ parentId.add(att.ParentId); } } if(parentId.size() > 0){ for(test_object__c tstObj :[SELECT Id,pickList__c,Checkbox_marked__c,Checkbox_Unmarked__c FROM test_object__c WHERE Id IN :parentId]){ maptestObjWIthId.put(tstObj.Id,tstObj); } } for(Attachment att: trigger.new){ if(att.ParentId != null && String.valueOf(att.parentId).startsWith(parentPrefix)&& !testObjProcessed.contains(att.parentId) && maptestObjWIthId != null && maptestObjWIthId.get(att.parentId) != null){ test_object__c tstobj = maptestObjWIthId.get(att.parentId); if(tstobj.pickList__c == 'Yes' && tstobj.Checkbox_marked__c && !Checkbox_Unmarked__c){ Checkbox_Unmarked__c = true; lstTestObjToUpdate.add(tstobj); testObjProcessed.add(tstobj.Id); } } } if(lstTestObjToUpdate.size() > 0){ update lstTestObjToUpdate; }}Regards,Bhanu Mahesh