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
shobana shobana 1shobana shobana 1 

Create a case clicking a custom button in Account object

My scenario is to create a Custom button in Account object while clicking that button it show some required field in Case their I want to add submit custom button after clicking that it will create a case record from that account.

I am pretty new to Salesforce development. Can anyone give me suggestion to do this.

Thanks in Advance.
Balu_SFDCBalu_SFDC
Try below Javascript for the Custom button.
{!REQUIRESCRIPT(“/soap/ajax/30.0/connection.js”)}
var c = new sforce.SObject(“Case”);
//your field values like
c.accountId='{!accountId}';
var result = sforce.connection.create([c]);
if(result[0].getBoolean(“success”)){
window.location = “/” + result[0].id + “/e”;
} else {
alert(‘Could not create record’ +result);
}
Balu_SFDCBalu_SFDC
Please do like below.

<apex:page standardController="Case" action="{!Save}">
<!--
do your logic here.
-->
</apex:page>
If you have any logic need to do in Save then call the custom controller in the page.like
<apex:page controller="yourClass" action="{!saveLogic}">
</apex:page>
Your Controller
------------------------
public class yourClass {
 public void saveLogic() {
   // your logic
   insert caserec;
}
}