Reputation: 1
Need some advise on how to populate a lookup field (contact) via apex trigger
trigger UpdateContactonComplaints on Idea (before insert, before Update) {
list<id> oid = new list<id>();
for(Idea o: trigger.new){
oid.add(o.id);
}
map<id, Idea> ExtendU = new map<id, Idea>(
[select CreatedbyID from Idea where id in: oid]);
for(Idea o: trigger.new){
o.Contact__c = ExtendU.get(o.id).CreatedbyID;
}
}
Upvotes: 0
Views: 2792
Reputation: 101
In the Trigger, the user id(id of the User who created the idea) is assigned to Contact custom lookup field).
So, it throws an error, data changed by trigger for field Contact: id value of incorrect type:
Upvotes: 0