You need to sign in to do that
Don't have an account?
bhutia
Change record types on click of a custom button
I have an application(custom object).I want to create a custom button named "submit" on application which when clicked change the record type of application.Please help
Hi Bhutia,
In the custom button onclick javascript, enter the following code:
{!REQUIRESCRIPT("/soap/ajax/12.0/connection.js")}
var recTypeName = "appRecTypeName"; // Change this to your record type name
var recordType = sforce.connection.query("Select ID, Name From RecordType WHERE Name = '" + recTypeName + "'");
var records = recordType.getArray("records");
var recordtypeID = records[0].Id;
var applicationRec = new sforce.SObject("Application__c"); // Custom object Application__c
applicationRec.ID = ID;
applicationRec.RecordTypeId = recordtypeID;
var result = sforce.connection.update([applicationRec]);
Let me know if you face any other issue.
Hi there,
I tried to copy the JS code to create a button on Opportunity object that upon clicking the button, it will mark the record type to Termination. However, i get an error message after putting it on the layout that says "token ILLEGAL".
Here is my code, can you tell me where i went wrong? Thanks!!
{!REQUIRESCRIPT("/soap/ajax/12.0/connection.js")}
var recTypeName = "012000000004wEC"; // Change this to your record type name
var recordType = sforce.connection.query("Select ID, From RecordType WHERE ID = '012000000004wEC''');
var records = recordType.getArray("records");
var recordtypeID = records[0].Id;
var applicationRec = new sforce.SObject("Application__c"); // Custom object Application__c
applicationRec.ID = ID;
applicationRec.RecordTypeId = recordtypeID;
var result = sforce.connection.update([applicationRec]);