You need to sign in to do that
Don't have an account?
Overriding the New button without disrupting flow
Scenario: When creating a new Event need to copy the content of a field in the related Contact record and place into a field in the Event. That info can than be further modified while on the Edit page.
Challenge: There are two page layouts for the Edit page of the Event object. We don't want to interrupt the establish flow of steps, just make the change to the brand new Event record and display the standard Edit page.
Being new I'm not sure of the best approach. I assume I should, in theory, do the following:
1. Create a controller extension
2. Create a VF page referencing the extension
3. Use an action attribute in apex:page to return the default page reference
4. Override the New button
button will fire page,
extension attribute will fire extension methods,
action attribute will fire the next step in the normal flow of steps.
Am I on the right track?
or should I be using a Trigger? Does the "before insert" event occur between the time the New button is clicked and the Edit page appears? I would assume not...
Thanks! S
Can you please clarify whether you have two page layouts or Record types?
Both. When creating a new Event, the user is presented with a choice of Record Type (distinct for each of two business units). The detail page has two Page layouts (again distinct for each business unit). Does that help?
Then you can go for a Trigger. Try this logic
trigger myTest on Event(before insert)
{
if(Trigger.isBefore)
{
for(Event evt:Trigger.new)
{
//field value from Contact
if(evt.WhoId != null)
{
String strValue=[select c.myField from Contact c where c.id= :evt.WhoId].myField;
evt.fieldXYZ=strValue;
}
}
}
}
Did this answer your question? If so, please mark it solved.
I'm coming back to this after the fact but there is no way without using a Trigger. What I really wanted was some way to make the change at the point the New Event was selected so that the user, when filling out the form, would see the change at this point. With a trigger the modification doesn't happen until they are done and have clicked "Save."
Andres Perez with Salesforce suggested that it would be possible to rebuild the New Event page from scratch but that seemed a rather large task for such a small change. My users were good with the trigger once I demoed it.