1. If we need to find out whether there are similar or the same records to the current

record, we can choose from the several methods, e.g.:

  • use soql
  • use search field in salesforce
  • manual finding

This method uses the standard function for searching records from Salesforce, but with already predefined search criteria (predefined is the field which will be searching for the duplicate records)

Create the button to find duplicate (for example for Account):

 

  • Setup -> Write to Quick find “Account” -> Buttons, Links, and Actions -> New Button or Link
  • Fill name, fill display Type, choose Behavior (Default in new window), choose Source to “URL” and insert the following code (duplicates search in your org based on Website):

 

/_ui/search/ui/UnifiedSearchResults?searchType=2&str={!LEFT(SUBSTITUTE( Account.Website, LEFT(Account.Website, FIND(“.”, Account.Website)), NULL), FIND(“.”, SUBSTITUTE(Account.Website, LEFT(Account.Website, FIND(“.”, Account.Website)), NULL))+3)}

2.,Secondly, the function for Owner change of the current login user can be helpful. If you have permission for this change, this function after click on the button change record owner to the current user.

Create button for change Owner

 

  • Setup -> Write to Quick find “Cases” -> Buttons, Links, and Actions -> New Button or Link
  • Fill name, fill display Type, choose Behavior (Execute Javascript), choose Source to “OneClick Javascript” and insert the following code:

{!REQUIRESCRIPT(“soap/ajax/13.0/connection.js”)}

 

var caseObj = new sforce.SObject(“CASE”);

caseObj.Id = ‘{!Case.Id}’;

caseObj.OwnerId = ‘{!$User.Id}’;

var result = sforce.connection.update([caseObj]);

 

if(result[0].success == ‘false’){

alert(result[0].errors.message);

}

else{

alert(‘Owner was changed’);

location.reload(true);

}

 

 

  • Customize code

 

    • In this line (var caseObj = new sforce.SObject(“CASE”);) replace “CASE” with your object API name.
    • In this line (caseObj.Id = ‘{!Case.Id}’;) replace the {!Case.Id} merge field with your object’s record Id merge field.
    • In this line (var result = sforce.connection.update([caseObj]);) replace “caseObj” with define variable name.

 

In a similar way we can create the button for changing record type on records to the predefined record type.  

Create button for change RecordType

 

  • Setup -> Write to Quick find “Opportunity” -> Buttons, Links, and Actions -> New Button or Link
  • Fill name, fill display Type, choose Behavior (Execute JavaScript), choose Source to “OneClick Javascript” and insert the following code:

 

Code:

{!REQUIRESCRIPT(“/soap/ajax/13.0/connection.js”)}

 

var oppObj = new sforce.SObject(“Opportunity”);

oppObj.Id = ‘{!Opportunity.Id}’;

oppObj.RecordTypeId = ‘01224000000LPyn’;

var result = sforce.connection.update([oppObj]);

 

if (result[0].success==’false’) {

  alert(result[0].errors.message);

}

else {

  alert(‘Record Type was changed’);

  location.reload(true);

}

 

 

  • Customize code

 

    • In this line (var oppObj = new sforce.SObject(“Opportunity“)) replace “Opportunity” with your object API name.
    • In this line (oppObj.Id = ‘{!Opportunity.Id}’) replace the {!Opportunity.Id} merge field with your object’s record Id merge field.
    • In this line () replace “RECORD TYPE ID” with your Record Type ID.  You can find the Record Type ID by going to the Record Types section of your object, clicking on the record type and grabbing the ID from the URL