+ Start a Discussion
Phuc 2Phuc 2 

loop through ProcessDefinition

Hello 
I am trying to loop through ProcessDefinition objet cbut it keep telling me I have an incorrect signature when trying to use .isempty()
 
List<ProcessDefinition> sfApprovalProcessList;

sfApprovalProcessList = [select Id, Name, 
DeveloperName, State, TableEnumOrId                                   FROM ProcessDefinition                                   WHERE State= 'Active' AND TableEnumOrId = 'Account'];

for (ProcessDefinition sfAppRecord : sfApprovalProcessList) {
   if (!sfAppRecord.isEmpty()){  ----error here----             sfApprovalProcessMap.put(sfAppRecord.DeveloperName,sfAppRecord);
  }
}
Any suggestion would be appreciated.
P
 
Best Answer chosen by Phuc 2
AnkaiahAnkaiah (Salesforce Developers) 
Hi Phuc,

try with below. you check list is emty before processing the for loop.
 
List<ProcessDefinition> sfApprovalProcessList;

sfApprovalProcessList = [select Id, Name, 
DeveloperName, State, TableEnumOrId    FROM ProcessDefinition                                   WHERE State= 'Active' AND TableEnumOrId = 'Account'];

   if (!sfAppRecord.isEmpty()){
for (ProcessDefinition sfAppRecord : sfApprovalProcessList) {
         sfApprovalProcessMap.put(sfAppRecord.DeveloperName,sfAppRecord);
  }
}

If this helps, Please mark it as best answer.

Thanks!!