You need to sign in to do that
Don't have an account?
Ajay Kumar 583
Need Apex Controller Code and vf page code
Hi , i have created a Button on Account object and Now i need the Apex controller code and visualforce page code Which will create a Contact when the user clicks the button. Please provide the code
Try below code hope this will work.
VF page: Create_contact
Apex Class: createCon
Create a detail page button on Account and add this vf page.
Do let me know if it helps you and close your query by marking it as solved.
Regards,
Santosh
All Answers
Greetings to you!
Below is the sample code which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Visualforce:
Controller:
Create a detail page button with content source as visualforce page and add it to page layout.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
i am getting the below error:
Insert failed. First exception on row 0 with id 0032v00002pPocnAAC; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]
And also i need to get Contact should be created without providing me the input values. It should create automatically create the some custom contact whenver i click the Button.
Thanks,
Ajay
Try below code hope this will work.
VF page: Create_contact
Apex Class: createCon
Create a detail page button on Account and add this vf page.
Do let me know if it helps you and close your query by marking it as solved.
Regards,
Santosh
Thanks a lot. its working . But why the Page is not refershing itself when i click the buttton.?
Replace the previous method with this one.
Thanks