You need to sign in to do that
Don't have an account?
dash27
Querying where object in list
I have a trigger that wants to create a list of all the ids of the triggering object. I initially tried this:
list<id> accIds = [select id from Account where Account in: trigger.new];
but that doesn't compile.
Is there a way to do this without using a for loop an iterating over all the objects in the trigger.new list?
Set<Id> accIds = Trigger.newMap.keySet();
Yes just change the code lil bit.
The above works for after insert , before update,after update nad not for delete because trigger.new doesnt exists for delete trigger.
List<Id> accIds = trigger.newMap.keyset();
or
list<id>ids=newlist<id>();
for(account a: trigger.new)
{
ids.add(a.id)
}