Skip to main content
hi can anybody write one apex class for  DML operation insert a record into the object and and copy past programme here  
1 answer
  1. Feb 5, 2015, 6:28 AM
    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>
0/9000