+ Start a Discussion

if the upload the pdf in related list of the Aaacount object then status Approved how is it Possible?

Please solve the problem my question is that 

if the upload the pdf in related list of the Aaacount object then status Approved how is it Possible?

thanks aklkk
Raj VakatiRaj Vakati
You mean you want to upload file from the approval process or back end ? or using some button ?? can u explain more 
no just want to trigger if the pdf or any other filed upload then parent field update approved if delete then show not approved (only field update )??
If I understand your requirement correct, You want to update one of the field( Say Approval Status) on Account when any of the attachment record would be created/updated/deleted.

You can use below code for your reference -
1.Create an Approval Status picklist field on Account with picklist value as "Approved" & "Not Approved".
2.Create a handler class, Copy & Paste the code below -
public class AttachmentTriggerHandler {
    public static void updateAccountStatus(List<Attachment> attchmentList,String status){
        List<Account> accountList = new List<Account>();
        Set<Id> accIds = new Set<Id>();

        for(Attachment att : attchmentList){
             //Check if added attachment is related to Account or not
             if(att.ParentId.getSobjectType() == Account.SobjectType){

        for(Account acc : [SELECT id, Approval_Status__c FROM Account WHERE id IN: accIds]){
            acc.Approval_Status__c = status;
        update accountList;

3.Create a trigger using Developer Console on Attachment object
trigger AttachmentTrigger on Attachment (after insert,after update,after delete) {
        if(Trigger.isInsert || Trigger.isUpdate){
        }else if(Trigger.isDelete){
            AttachmentTriggerHandler.updateAccountStatus(Trigger.old,'Not Approved');

Now, Salesforce recommends to use Salesforce files over Attachment. You have to change the code and move it to Content document in that case. Keep posting here if you have any further doubts.

Happy Coding!