Custom button to change record type and status in Salesforce

In Salesforce, “Record Types” are a way to arrange and classify data in an object. An example of howRecord Types can be particularly helpful is when you want to assign different sets of data to different groups of sales teams.

Whenever you’re working to customize or change something in Salesforce and need to reference Record Types, you must have the appropriate Record-Type ID. There are two ways to find them:

  • Go to the Record Type (Setup> Customize> (object)> Record Types). Click on the record type. Find the Record Type ID in the URL between id= and &type.

Alternatively, you can create a custom/formula field with the value Record-Type ID.

  • Go to Your Name> (appropriate object) Customize> Fields> under custom fields,
  • Click “New“.
  • Make sure you pick Formula as the type and then Formula Text and click Next.
  • You can label the field “Record Type“.
  • Finally, enter “RecordTypeid” under Advanced Formula tab.
  • Don’t forget to hit “Save“.
Created by: Mark Miller 
Last Update: 18 September 2015 

- Updates selected quote record with a status of "PO Received" 
- Updates selected quote record with a record type of "PO Received" 
- Display Type is "List Button" 
- Behavior is "Execute JavaScript" 
- Content Source is "OnClick JavaScript" 
{!REQUIRESCRIPT('/soap/ajax/34.0/connection.js')} //adds the proper code for inclusion of AJAX toolkit 

var q = new sforce.SObject('Quote'); = '{!Quote.Id}'; 

q.Status = "PO Received"; 

q.RecordTypeId = '012j0000000zNVn' 
result = sforce.connection.update([q]);