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
Sascha DeinertSascha Deinert 

Trigger Relationship Field

Hello, 

I have a very simple trigger which is working fine in the sandbox but it doesn't work in the production. If someone change the owner of the opportunity or add a new opportunity the customfield team__c should be filled with the owner team value. But if I change the owner the field keep blank. If I change the team field at the opportunity manuelly and then I change the owner then becomes the field also blank.
 
trigger setTeamOpportunity on Opportunity (before update) {

 for(Opportunity o : trigger.new) { 
     Opportunity oldOpportunity = trigger.OldMap.get(o.ID);
         if(o.ownerid != oldOpportunity.ownerid) {
                    o.Team__c = o.Owner.Team__c;
         }
     }
}
Can someone help me please.

Thanks,
Sascha