• Anthony Garand
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hello Everyone,

Pretty simple question, I have this apex trigger ready to go; But I am unsure where to place it. It updates contacts and opportunity owners to match the account owner, So I am assuming I put it under the account triggers? 
Here is the code.

trigger reassignContactOwnerToAccountOwner on Contact ( before insert, before update ) {

    List<Id> accountIds = new List<Id>();
    Map<Id, Id> accountOwnerIdMap = new Map<Id, Id>();

    // all the accounts whose owner ids to look up
    for ( Contact c : Trigger.new ) {
        accountIds.add( c.accountId );
    }
    
    // look up each account owner id
    for ( Account acct : [ SELECT id, ownerId FROM account WHERE id IN :accountIds ] ) {
        accountOwnerIdMap.put( acct.id, acct.ownerId );
    }
    
    // change contact owner to its account owner
    for ( Contact c : Trigger.new ) {
        c.ownerId = accountOwnerIdMap.get( c.accountId );
    }
   
}

 
Hello Salesforce Developers!

I am trying to add a custom checkbox to the contact page,
This checkbox will say "Inactive" with a check box next to it on the detail page.


User-added image'

Much like the Email Opt Out check box. 

Any help will be greatly appreciated! Thank you for your time.

Tony Garand.
Hello, I am curious how to make a apex controller or script to automate an activation process ( for over 900 contacts in a list)

User-added image
Here is the button I am trying to automate 

User-added image

Any help will be greatly appreciated! 

Thank you,

Tony.
Hello, I am curious how to make a apex controller or script to automate an activation process ( for over 900 contacts in a list)

User-added image
Here is the button I am trying to automate 

User-added image

Any help will be greatly appreciated! 

Thank you,

Tony.