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
krishna chaitanya 35krishna chaitanya 35 

Help with update operation -Unable to pass the ID

Can any one help me with the update operation
​​​​​​​public class AccountUpdateWithDelegated {
public static void fillDelegatedApproverEmail(Set<id>  accn) {
List<ProcessInstance> pi = new List<ProcessInstance>();
Map <ID,ID> prinst =new Map<ID,ID>();
Map <ID,ID> Prsinswi =new Map<ID,ID>();
Map <ID,ID> userndelegated =new Map<ID,ID>();
List < Account > ac = new List < Account > ();
pi=[select id,Status,TargetObjectId ,LastActorId from  ProcessInstance where  TargetObjectId IN :accn];

for (ProcessInstance ps : pi){
prinst.put(ps.TargetObjectId,ps.id);
system.debug('list of id '+prinst);
}

List<ProcessInstanceWorkitem> piw = new List<ProcessInstanceWorkitem>();

piw =[select id,ActorId,ProcessInstanceId from ProcessInstanceWorkitem where ProcessInstanceId IN :prinst.values()];
for (ProcessInstanceWorkitem psiw :piw){
    Prsinswi.put(psiw.id,psiw.ActorId);
    system.debug('list of process instance items in piws'+prinst.values());
}
 
List<user> us = [select id,DelegatedApproverId,Email,createdbyid,isactive from user where DelegatedApproverId!= NULL and ID IN :Prsinswi.values()];

system.debug('Delegated approver '+us);
for(user usrs :us){
userndelegated.put(usrs.id,usrs.DelegatedApproverId);
    system.debug('set of delegated id '+userndelegated);
}
List <user> us1 = [select id,email from user where id IN:userndelegated.values()];
for (user usrss : us1) {
            Account acce = new Account();
            acce.Delegated_Approver_Email__c = usrss.email;
            //acce.id = prinst.get.ps.TargetObjectId;
            system.debug('Delegated_Approver_Email__c' + acce.Delegated_Approver_Email__c);
            ac.add(acce);
        }
    If (!ac.isEmpty()){
        update ac;
    }
}
}

Can any one help me with the update operation
ANUTEJANUTEJ (Salesforce Developers) 
Hi Krishna,

Can you elaborate on the issues you are facing and also the scenario so that we can check it.

Regards,
Anutej