You need to sign in to do that
Don't have an account?
turbo2oh
simple syntax question
What is wrong with this syntax inside a before insert/before update trigger please?
set <id> locationIds= new set<id>{ trigger.newMap.keySet()};
I'm getting the error: Invalid initial value type SET<Id> for SET<Id> which isn't very helpful. I'm just trying to define a variable name for the trigger.newMap.keySet() so its more readable.
You are using the wrong braces.
Thanks! Also, I realized the fundamental problem, there isn't going to be an id for a before insert trigger since its not inserted yet.
You can also do this:
But you might not even need to do that. After all, you can use Trigger.new in a query (it implements Iterable, and can be used directly).
Which saves a bit on heap space (not that a set of IDs will abuse the heap too much...).
Edit: Yea, I just noticed that you had it in a before insert trigger. That recently found its way to my attention as well in my own project.