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
ashok dadali 3ashok dadali 3 

DML opearion

hi can anybody write one apex class for  DML operation insert a record into the object and and copy past programme here  
MaddyConnectMaddyConnect
public class InsertRecord 
{
    sObject rec;
    boolean result = false;
    public boolean addRecord(string objName)
    {
        if(objName == 'Account')
        {
            rec = new Account(name='test');
            insert rec;
            result = true;
        }
        return result;
    }
    public void ClickMe()
    {
        boolean res = addRecord('Account');
    }
}

Here you can call method ClickMe from visualforce page to create account record. Below will be example VF page:

<apex:page controller="InsertRecord">
    <apex:form>
        <apex:commandButton action="{!clickme}" value="Create Account"/>
    </apex:form>
</apex:page>