You need to sign in to do that
Don't have an account?
Variable does not exist? I just declared it!
Compile Error: Variable does not exist: atm at line 52 column 32
it's hitting on the line atms.add(atm); but I just declared the atm the line before - please assist! I must be missing something obvious? Thanks!
trigger UserActivatedTeamCoverage on User (after insert, after update) { //when a user is activated or inserted, the should be added to the AccountTeams of Accounts they cover via TeamMember // declare some lists List < EntitySubscription > esSet = new List < EntitySubscription > (); List < AccountTeamMember > atms = new List < AccountTeamMember > (); List <coverage_Person__c> CPS = new List <Coverage_Person__c> (); List < Double > empIds = new List < Double > (); List < ID > UserID = new List < ID > (); List < AccountShare > ASSES = new List < AccountShare > (); //add info from the users to the lists for users who are active and have an EMP_id (all should!) For (User u1:trigger.new){ if(u1.isActive=true) if (u1.EMP_id__c !=null) empIds.add(u1.Emp_Id__c); UserID.add(u1.id); } //get a list of team memberships for this person List <Coverage_Person__c> CP3 = [select name, id, emp_id__c, Coverage_Team__c from Coverage_Person__c where emp_id__c IN: empIds]; system.debug('CP3 the list of coverages=========================='+cp3); //add the teams to a list List <id> CP3Teams = new List <ID>(); for(Coverage_person__c es:cp3){CP3Teams.add(es.Coverage_Team__c);} system.debug('CP3Teams=======================the teams ids'+CP3Teams); //get the assigned teams of these Teams List <Assigned_Team__c> Assignments = [select name, id, emp_id__c, Account__c from Assigned_Team__c where Coverage_team__c IN: CP3Teams or EMP_id__c IN: empIds]; system.debug('assignments========assigned teams========'+Assignments); //add the ids of the accounts from the AssTeams to a list List <id> AssignmentsAccounts = new List <id>(); for (Assigned_Team__c os:Assignments){AssignmentsAccounts.add(os.Account__c);} system.debug('Assignments Accounts ids ======================= '+AssignmentsAccounts); //loop through User and find the link to the account, then create an accountTeamMember record for them For (User u1:Trigger.new){ For (Coverage_Person__c C:CP3){ if(c.User__c==u1.id) For (Assigned_Team__c at:Assignments){ if(at.Coverage_Team__c==c.Coverage_Team__c) AccountTeamMember atm = new AccountTeamMember (AccountID=at.Account__c, UserId=u1.id, TeamMemberRole='Coverage'); atms.add(atm); } } } insert atms; }
You are missing the brackets :D
My advice.. always uses open and closer bracket, do not matter if you have only one sentence.
Regards!
All Answers
You are missing the brackets :D
My advice.. always uses open and closer bracket, do not matter if you have only one sentence.
Regards!
thanks!