+ Start a Discussion
javierjiesjavierjies 

Owner Control

Hello everyone!

 

Do you know if is there any way to make a counter to know how many times has a Lead changed his owner?

 

 

Thanks in advance!

Best Answer chosen by Admin (Salesforce Developers) 
CaptainObviousCaptainObvious

Another possible solution using workflow:

 

First create a new field on the Lead object:
Field Label: Changed Owner
Data Type: Number
Length: 18
Decimal Paces: 0
Default Value: 0

 

Next create a workflow rule:
Object: Lead
Evaluation Criteria: Every time a record is created or edited
Rule Criteria: PRIORVALUE(OwnerId) != OwnerId

 

Now add a workflow field update:
Field to Update: Changed Owner
Use a formula to set the new value: Changed_Owner__c + 1

 

This should accurately track the number of times NEW leads change owner.

 

For pre-existing Leads (assuming you had tracking history enabled for Lead Owner) you would have to manually update the initial value.

All Answers

Ispita_NavatarIspita_Navatar

You can have a field called "OwnerChangeCounter__c" and use a trigger which works / fires if(trigger.new[0].ownerid<> trigger.old[0].ownerid) , and increment the value of Counter by 1 everytime the condition is fulfilled (owener is changed).

Code Snippet:-

trigger CaseTgr on Case (before update) {
    if(trigger.new[0].ownerid != trigger.old[0].ownerid)
    {
 
      if(trigger.old[0].counter__c==null)
      {
      Trigger.new[0].nav_isp__Counter__c= 1;
      }
      else
      {
     Trigger.new[0].nav_isp__Counter__c= trigger.old[0].nav_isp__Counter__c + 1;
          }
    }
   
}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

CaptainObviousCaptainObvious

Another possible solution using workflow:

 

First create a new field on the Lead object:
Field Label: Changed Owner
Data Type: Number
Length: 18
Decimal Paces: 0
Default Value: 0

 

Next create a workflow rule:
Object: Lead
Evaluation Criteria: Every time a record is created or edited
Rule Criteria: PRIORVALUE(OwnerId) != OwnerId

 

Now add a workflow field update:
Field to Update: Changed Owner
Use a formula to set the new value: Changed_Owner__c + 1

 

This should accurately track the number of times NEW leads change owner.

 

For pre-existing Leads (assuming you had tracking history enabled for Lead Owner) you would have to manually update the initial value.

This was selected as the best answer