You need to sign in to do that
Don't have an account?
andyaldis1.3969086903835708E12
Add ids from a list to a set without a for loop
I am looking for a way to to add Look up Ids from a query to a set without using a for loop. I am essentially looking for the most efficient way to write the code below. I have found techniques using keyset() but that only pulls in the Id of the task relation object.
set<Id> retActivityIdList = new Set<Id>();
List<taskRelation> taskRelationList = [SELECT TaskId FROM taskRelation WHERE relationId = :contId ORDER BY CreatedDate DESC ];
IF(!taskRelationList.isEmpty()){
for(taskRelation tr: taskRelationList){
retActivityIdList.add(tr.TaskId);
}
}
set<Id> retActivityIdList = new Set<Id>();
List<taskRelation> taskRelationList = [SELECT TaskId FROM taskRelation WHERE relationId = :contId ORDER BY CreatedDate DESC ];
IF(!taskRelationList.isEmpty()){
for(taskRelation tr: taskRelationList){
retActivityIdList.add(tr.TaskId);
}
}
Wilfredo,