+ Start a Discussion
karthick S 28karthick S 28 

Create New case record by custom button

Anyone how to create a new case record and also redirect to a vf page using custom button.

please let me know is any possiblities is there?

Thanks in advance.

VamsiVamsi
HI,

Create a custom button with on click java script and use the below code to create a new record and redirect to new visualforce page 

Create a new record 

var account = new sforce.SObject("Account");
account.Name = "my new account";
var result = sforce.connection.create([account]);
if (result[0].getBoolean("success"))
{
log("new account created with id " + result[0].id);
}
else
{ log("failed to create account " + result[0]);
}

To redirect to new VF page 

var newwindow = window.open('/apex/your vf page name?caseid={!Case.Id}','_blank', 
'height=300,width=400,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,left=500,top=100');

******** caseid={!Case.Id} - Its a vf page parameter you can remove it, If you don't want ***

Please mark as a best answer if the above helps