• vivek@shack.co.in
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies

Hi,

I am still in process of learning APEX coding. However I need to do a Trigger urgently.

I wrote trigger with the help of a blog and it works great. Now, I need Test Method to deploy it in production.

Trigger:

trigger ownerCopy on Account(Before Insert, Before Update) {

    // handle arbitrary number of opps
    for(Account x : Trigger.New){

        // check that owner is a user (not a queue)
        if( ((String)x.OwnerId).substring(0,3) == '005' ){
            x.Owner_2__c = x.OwnerId;
        }
        else{
            // in case of Queue we clear out our copy field
            x.Owner_2__c = null;
        }
    }

}

I am trying myself using this documentation, however any help will be greatly appretiated.

Regards,

Hi,

I am still in process of learning APEX coding. However I need to do a Trigger urgently.

I wrote trigger with the help of a blog and it works great. Now, I need Test Method to deploy it in production.

Trigger:

trigger ownerCopy on Account(Before Insert, Before Update) {

    // handle arbitrary number of opps
    for(Account x : Trigger.New){

        // check that owner is a user (not a queue)
        if( ((String)x.OwnerId).substring(0,3) == '005' ){
            x.Owner_2__c = x.OwnerId;
        }
        else{
            // in case of Queue we clear out our copy field
            x.Owner_2__c = null;
        }
    }

}

I am trying myself using this documentation, however any help will be greatly appretiated.

Regards,