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
aklkkaklkk 

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

Hi,all 
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 
aklkkaklkk
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 )??
DevADSDevADS
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){
                  accIds.add(att.ParentId);
             }
        }

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

3.Create a trigger using Developer Console on Attachment object
trigger AttachmentTrigger on Attachment (after insert,after update,after delete) {
    
    if(Trigger.isAfter){
        if(Trigger.isInsert || Trigger.isUpdate){
            AttachmentTriggerHandler.updateAccountStatus(Trigger.new,'Approved');
        }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!