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
guna malliguna malli 

I have object like "A", In this object have 4 fields and i created one custom button "insert" ,i created vf page for button,when ever i click on insert button open that page there i click on save button i want insert record in "A" object

I have object like "A", In this  object have 4 fields and  i created one custom button like "insert" and also i created vf page for that custom button,now i want to without give any fieldvalues on vf page level .this means i have no inputfields ,in page level i have only "insert" button .when ever i click on insert button i need to insert the record. How can achieve this by using apex class
Paras_BhattParas_Bhatt

your Apex class must have method that can be invoked from the button.

The method should have code like

//initilize your object
ObjA tempRec = new ObjA();
// set field values
tempRec.field1__c= 'Some Value';
tempRec.field2__c= 'Some Value';
tempRec.field3__c= 'Some Value';
tempRec.field4__c= 'Some Value';
// Insert record
insert tempRec;


If you want complete process to be automated where user don't even need to click on Insert button, You can call the method from VF page's action attribute.

Let me know if that helps,

Thanks and Regards,

paras Bhatt