function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Edward Scott 5Edward Scott 5 

Trigger not firing when using dataloader


I was just able to get this trigger to work yesterday with the help of the community. It updates a field on the opportunity object from the opportunity team member page. It works fine whe I create an opportunity or edit one but it doesn't work when I use data loader. I am new to apex code and I saw an article about first creating a set in order to get the trigger to be a bulk trigger but I am not sure how to do it.  Here is my code I was wondering if anyone could help me. 
Trigger updateAdOps on Opportunity (after update, after insert) {

  // Get Ad Ops team members & put in a map of <OpportunityId,AdOpsTeamMemberId>
  map<id,id> mOtms = new map<id,id>();
  list<OpportunityTeamMember> otms = new list<OpportunityTeamMember>([
      SELECT id,opportunityId,TeamMemberRole,UserId 
      FROM OpportunityTeamMember
      WHERE opportunityId IN :trigger.newmap.keyset()
        AND TeamMemberRole = 'Ad Ops'

  For(OpportunityTeamMember otm :otms) {

  // Re-aquire the Opportinities and Update them with the Ad Ops team member
  list<Opportunity> opportunitiesToUpdate = new list<opportunity>([SELECT id,Ad_Ops_Contact1__c FROM   Opportunity WHERE Id IN :trigger.newmap.keyset()]);
  for(Opportunity o :opportunitiesToUpdate) {
      o.Ad_Ops__c = mOtms.get(;

  if (util_utilities.alreadyExecuted != true) {
    util_utilities.alreadyExecuted = true;
    if(opportunitiesToUpdate.size()>0) {
      update opportunitiesToUpdate;


Have you monitored the Debug Logs to see if your trigger even fires.  My guess is that it is firing and something else is setting util_utilities.alreadyExecuted to true and it's skipping lines 24-29.
Edward Scott 5Edward Scott 5
I haven't. How do I check the debug logs? I'm an admin an I'm studying to get my masters in comp sci but I'm pretty new to apex code so this is all kinda new to me this is only the second trigger that I have written. I really appreciate all of your help.