[英]Apex Trigger to Update Lookup Field (Contact)
Need some advise on how to populate a lookup field (contact) via apex trigger 需要一些关于如何通过顶点触发器填充查找字段(联系人)的建议
trigger UpdateContactonComplaints on Idea (before insert, before Update) { 触发Idea上的UpdateContactonComplaints(在插入之前,更新之前){
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;
}
} }
In the Trigger, the user id(id of the User who created the idea) is assigned to Contact custom lookup field). 在触发器中,将用户ID(创建想法的用户的ID)分配给联系人自定义查找字段)。
So, it throws an error, data changed by trigger for field Contact: id value of incorrect type: 因此,将引发错误,触发器的字段Contact:ID值类型不正确的数据已更改:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.