function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Button to update Record Type ID

I would like to create a button that changes the record type of a case . 


I have tried writing the javascript and scoured the web, but still cannot get it to work.  My code will update other fields if modified but not the recordtypeid.  Any suggestions?



var undocase= new sforce.SObject("Case"); = "{!Case.Id}";
undocase.RecordType = "01240000000QFLB";

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

if (result[0].getBoolean("success"))
    // Refresh window
    alert("Error saving case");

Ritesh AswaneyRitesh Aswaney

Try RecordTypeId

undocase.RecordTypeId = "01240000000QFLB";


I have tried both recordtype and recordtypeid,  neither one leads  to a record type change on the record.


Do you have a workflow or Apex trigger, written which might be resetting the recordType value


I guess you have not created any record type in case object so first you need to create record type then before updating the

record type you just query that record type then update in case object.


Find below a sample code:


RecordType RT = [select id from RecordType where name='CaseRecType' and SobjectType ='Case' limit 1];

Case cs = [Select id, RecordTypeId from Case limit 1];

cs.RecordTypeId =;

update cs;