You need to sign in to do that
Don't have an account?
Finney
Button to change record type
Hi
I have 2 record types on Account
For Example
1) Live Prospect
2) Dead Prospect
I want to have a button on the live prospect, which when pressed turns the Live prospect record type to a dead prospect.
I want to name the button as KILL. So when the KILL button is pressed, LIVE record type should change to DEAD
Can anyone please help me with the code for the button .
Thanks
Finney
Hi SFDC@Fuj
Thanks a lot for your help.
With a bit of customisation it worked.
var recordtype= sforce.connection.query("select name, id from recordtype where name='Dead'");
var records = recordtype.getArray("records");
try
{
if('{!Account.RecordType}' == 'Live Prospect')
{
sforce.connection.sessionid = '{!GETSESSIONID()}';
var account = new sforce.SObject("Account");
account.id='{!Account.Id}';
account.RecordTypeId =records[0].Id;
var result = sforce.connection.update([account]);
}
}
catch (ex)
{
alert(ex);
}
if (result[0].success=='false') {
alert(result[0].errors.message);
} else {
location.reload(true);
}
Kind Regards
Finney
All Answers
Hi,
Set the Behavior 'Execute javascript ' and Content Source 'On Click Java Script' for Kill button. Use the following code as a reference.
{! REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}
var recordtype= sforce.connection.query("select name, id from recordtype where name='Dead prospect'");
var records = recordtype.getArray("records");
try
{
if('{!Account.RecordType}' == 'Live prospect')
{
sforce.connection.sessionid = '{!GETSESSIONID()}';
var account = new sforce.SObject("Account");
account.id='{!Account.Id}';
account.name='hello121';
account.RecordTypeId =records[0].Id;
var result = sforce.connection.update([account]);
}
}
catch (ex)
{
alert(ex);
}
Did this answer Help you? If not, let me know the issue.
Hi SFDC@Fuj
Thanks a lot for your help.
With a bit of customisation it worked.
var recordtype= sforce.connection.query("select name, id from recordtype where name='Dead'");
var records = recordtype.getArray("records");
try
{
if('{!Account.RecordType}' == 'Live Prospect')
{
sforce.connection.sessionid = '{!GETSESSIONID()}';
var account = new sforce.SObject("Account");
account.id='{!Account.Id}';
account.RecordTypeId =records[0].Id;
var result = sforce.connection.update([account]);
}
}
catch (ex)
{
alert(ex);
}
if (result[0].success=='false') {
alert(result[0].errors.message);
} else {
location.reload(true);
}
Kind Regards
Finney