You need to sign in to do that
Don't have an account?

Error in simple trigger to populate lookup field
Hi all,
Iam getting an error in the line highlighted below.Is this the correct way to write it
trigger updateGroupLookup on Case (before insert) {
for (Case c : Trigger.new) {
if(c.groupid__c!= null){
c.group_Account__c = [select id from account where Group_ID__c =c.groupid__c];
}
}
}
c.group_Account__c = [select id from account where ID=:c.groupid__c].ID;
let me know error if it not works.
All Answers
c.group_Account__c = [select id from account where ID=:c.groupid__c].ID;
let me know error if it not works.
trigger updateGroupLookup on Case (before insert,before update) {
for (Case c : Trigger.new) {
if(c.groupid__c!= null){
c.group_Account__c = [select id from account where Group_ID__c=:c.groupid__c].ID;
}
}
}
working fine now