You need to sign in to do that
Don't have an account?
Kevin Languedoc
Update Case Owner
I have a picklist field that has a list of the Queue groups as values. When the case initiator creates a case, they must either assign it to one of the groups in the Queue or keep it. If they assign to a Queue, the owner field must be updated with this new value and an e-mail must be sent to the new owners.
When I deploy to sandbox, which is successful, I get this error message from the APex editor in the sandbox
Error: Compile Error: Variable does not exist: Trigger at line 5 column 18
trigger UpdateCaseOwner on Case (before update) {
//select Id, Name from Group where Name = 'QA' and Type = 'Queue'
for(Case c : Trigger.new()){
List<Group> qid = [select Id from Group where Name = : c.CaseAssignedOwner__c and Type = 'Queue'];
for(Group g : qid){
c.OwnerId = g.id;
}
}
}
When I deploy to sandbox, which is successful, I get this error message from the APex editor in the sandbox
Error: Compile Error: Variable does not exist: Trigger at line 5 column 18
trigger UpdateCaseOwner on Case (before update) {
//select Id, Name from Group where Name = 'QA' and Type = 'Queue'
for(Case c : Trigger.new()){
List<Group> qid = [select Id from Group where Name = : c.CaseAssignedOwner__c and Type = 'Queue'];
for(Group g : qid){
c.OwnerId = g.id;
}
}
}
In for loop, you should be using Trigger.new instead of using Trigger.new() since it is not a function.
trigger UpdateCaseOwner on Case (before update) {
//select Id, Name from Group where Name = 'QA' and Type = 'Queue'
for(Case c : Trigger.new){
List<Group> qid = [select Id from Group where Name = : c.CaseAssignedOwner__c and Type = 'Queue'];
for(Group g : qid){
c.OwnerId = g.id;
}
}
}
All Answers
In for loop, you should be using Trigger.new instead of using Trigger.new() since it is not a function.
trigger UpdateCaseOwner on Case (before update) {
//select Id, Name from Group where Name = 'QA' and Type = 'Queue'
for(Case c : Trigger.new){
List<Group> qid = [select Id from Group where Name = : c.CaseAssignedOwner__c and Type = 'Queue'];
for(Group g : qid){
c.OwnerId = g.id;
}
}
}