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
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.


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);
{ log("failed to create account " + result[0]);

To redirect to new VF page 

var newwindow ='/apex/your vf page name?caseid={!Case.Id}','_blank', 

******** 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