2

Iam using SAVE and DELETE Buttons in Visualforce page. And when i click the SAVE button it will be insert in account object.But How to delete the same record(when i click the DELETE button). How is it possible, Plese Help me.

1
  • Is this a visualforce page where there is a list of Accounts and associated buttons with them?
    – ajinkyah
    Jul 9, 2015 at 12:41

2 Answers 2

2

You can do this way Also.....

    public Account ac;
    public void Create(){

        ac = new Account(name='MyAccount');
        insert ac;

    }
    public void delete(){
       if(ac.id! = null){ 
        delete ac;
       }
    }
0
1

You can use standard controller action to do this. Use

<apex:commandButton action="{!delete}" value="Delete"/>

to delete the record currently in context.

For this to work, you should pass ?id=001xxxxxxxxxxxx at the end of your url.

Refer: Using Standard Controller Actions

Hope it hleps.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .