5

Can we use <apex:detail> to get the layout of standard object on a VF page.

<apex:page standardcontroller ="Event">
<apex:detail subject="{!Event.Id}"/>
</apex:page>

I can view the event record by using the above code. But i wanted to see if we can use apex:detail to add new record. If i remove subject="{!Event.Id}" then we have a blank screen.

Is there anyway we have the layout for new record built in VF page?

Thanks

  • Do you mean that you want to override Event's 'New' button? – Priyanka Nov 27 '12 at 5:18
  • I wanted to have the layout of Event as a part of a Vf page. I would have the save button on my Vf page all the saving functionality would be taken care of in my controller, i just wanted to display the layout as it is in the page layout – Prady Nov 27 '12 at 6:56
  • So, you only need page detail with editable functionality? You don need to create a new record ? – Priyanka Nov 27 '12 at 7:08
  • i only want to create a new record, instead of me creating all the fields in the VF page can we show the layout with input fields in it. Apex:detail with subject shows the field layout for that record. i wanted to have something similar for new record along with some other extra information from another object and have one save button on Vf page – Prady Nov 27 '12 at 8:56
  • That's not possible. The <apex:detail> is for already created record. You can edit the already existing record in the <apex:detail> tag using inlineEdit attribute. But in you case you want to create a new record, so you should create a VF page with all the fields that you need. If you have a recordtype for event, then its your choice to select the record type or not while overriding 'New' button with an option 'Skip Record Type Selection Page' – Priyanka Nov 27 '12 at 9:22
8

Follow the steps to override the Event's New button with a VF page

1.Create a VF page 'NewEventPage' with the following code

<apex:page standardController="Event">
<!-- Add the fields that you need -->
</apex:page>

2.Go to Setup -> Customize -> Activities -> Events Buttons and links

3.Edit new button, now the created 'NewEventPage' will be displayed in the 'Override with' options

4.Select the page and save

5.Now if you click 'New' button, the VF page will be displayed.

Adding comment to the answer:

The <apex:detail> is for already created record. You can edit the already existing record in the <apex:detail> tag using inlineEdit attribute. But in you case you want to create a new record, so you should create a VF page with all the fields that you need. If you have a recordtype for event, then its your choice to select the record type or not while overriding 'New' button with an option 'Skip Record Type Selection Page'

  • cant figure out why one should do a -ve marking for @priyanka – Prady Nov 27 '12 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.