我是apex编码的新手。请参阅下面的触发器,当优先级高的票证被提升时,它会创建一个任务。除此行外,触发器有效:// t.Owner = Tickets__c.Assigned_To__c;
我正在尝试通过自定义故障单对象中的字段Assigned_To__c来接收分配故障单的用户,然后创建一个任务,其中任务的所有者与分配给'的用户相同39;票证对象中的字段捕获。
触发编译除注释行外:
在Tickets__c上触发AssignTicket(在插入后,在更新后){
for(Tickets__c tkt : trigger.new){
if(tkt.Priority__c == 'High'){
task t = new task();
t.Subject = 'Ticket has been assigned to you!';
t.Status = 'Not Started';
t.Priority = 'Normal';
//t.Owner = Tickets__c.Assigned_To__c.; **[Need help with this line]**
t.WhatId = tkt.id;
insert t;
}
}
答案 0 :(得分:0)
将插件从循环中取出并设置OwnerID,而不是所有者。
List<Task> lInsert = new List<Task>();
for(Tickets__c tkt : trigger.new){
if(tkt.Priority__c == 'High'){
task t = new task();
t.Subject = 'Ticket has been assigned to you!';
t.Status = 'Not Started';
t.Priority = 'Normal';
t.OwnerID = Tickets__c.Assigned_To__c.; **[Need help with this line]**
t.WhatId = tkt.id;
lInsert.Add(t);
}
}
insert lInsert;