You need to sign in to do that
Don't have an account?
Iman Nazarian
Record type change with OnClick button
Hi everyone
I am trying to change the record type of my case with the click of a button. The id of the record type I would like to change to is 012550000000AS0. I have this peace of code, it does not work currently... I get an error message saying "Unexpected token case"
{! REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}
var recordtype= sforce.connection.query("select name, id from recordtype where name='Dead'");
var records = recordtype.getArray("records");
try
{
if('{!Case.RecordType}' == 'Live Prospect')
{
sforce.connection.sessionid = '{!GETSESSIONID()}';
var account = new sforce.SObject("Case");
account.id='{!Case.Id}';
account.RecordTypeId =records[0].Id;
var result = sforce.connection.update([case]);
}
}
catch (ex)
{
alert(ex);
}
if (result[0].success=='false') {
alert(result[0].errors.message);
} else {
location.reload(true);
}
I am trying to change the record type of my case with the click of a button. The id of the record type I would like to change to is 012550000000AS0. I have this peace of code, it does not work currently... I get an error message saying "Unexpected token case"
{! REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}
var recordtype= sforce.connection.query("select name, id from recordtype where name='Dead'");
var records = recordtype.getArray("records");
try
{
if('{!Case.RecordType}' == 'Live Prospect')
{
sforce.connection.sessionid = '{!GETSESSIONID()}';
var account = new sforce.SObject("Case");
account.id='{!Case.Id}';
account.RecordTypeId =records[0].Id;
var result = sforce.connection.update([case]);
}
}
catch (ex)
{
alert(ex);
}
if (result[0].success=='false') {
alert(result[0].errors.message);
} else {
location.reload(true);
}
That - or you can create a checkbox on the Case that says "Dead" - and then have workflow fire to change the RecordType based on that checkbox being on. That is a zero-code solution, but a two-click (check, save) for the user.