function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tsmith.ax677tsmith.ax677 

Overiding a standard button (using visualforce) with a simple custom URL...

This should be very simple, but I've been unable to find any example documentation to get this working.

 

Any help would be extremely appreciated!

 

I simply want to pre-fill some fields when a user creates a new record. I have successfully accomplished this by creating a Custom Button with the following URL setup:

 

 

This Custom Button works great, except instead of a Custom Button, I want to Override the "New" standard button for the object with this same URL logic.

 

What would the equivalent code for my visualforce page look like?

 

I've even tried such things as:

 

 

<apex:page StandardController="Application__c" action="https://na5.salesforce.com/a0R/e?CF00N700000024t7L={!HTMLENCODE(Opportunity.Name)}&CF00N700000024t7L_lkid={!Opportunity.Id}&retURL=%{!Opportunity.Id}&CF00N700000025GKF={!$User.FirstName}&CF00N70000002525I={!Opportunity.Contact__c}&CF00N700000024tek={!Opportunity.Account}"/>


</apex:page>

 

 

Additional details:

 

- This is a custom object called "Application" that I am trying to have some fields be "pre-filled" for.

- Generally, users currently click "New Application" standard button from an "Opportunity". I want to Override this "New Application" button with the above URL.

 

Any help would be greatly appreciated!

 

Thank you!!

Benajmin PirihBenajmin Pirih

Hello tsmith,

 

I think you are heading down the wrong path.  If you need to have default values for the page then you should just set the default value on the fields via setup. 

 

If these values need to be set using some type of logic, you would be best off using a trigger on the before or after insertion depending on your needs.

 

If you create a visualforce page then you will have to code this visualforce page and handle the updates and changes to this page.  This would require you to redevelop the standard page which you are currenlty using and replace it with your new custom visualforce page. 

 

To answer your question below you can override any standard button to a visualforce page using the built in mechnaism provided by salesforce.com  Search for overriding a standard button to visualforce page.

 

I think you should really push for the trigger update if possible.  Hope this helps.

 

Thanks, Benjamin Pirih

 

 

tsmith.ax677tsmith.ax677

Thank you very much for your response!

 

I am very surprised that salesforce does not allow me to simply use the basic logic of my "updated URL with additional parameters" idea (which works perfectly with a Custom Button).

 

Instead, they would require me to manually re-create the entire page with a visualforce page, which would not be worth the trouble.

 

Notes:

1. ) All of these fields are "Lookup" data types, which cannot have default values assigned to them through salesforce config.

 

2.) Also, I want the users to be able to see the values populated as the load the page, instead of relying on a trigger (which would only update afterwards).

 

 

I guess maybe I'll get users to use the Custom Button for now on, and somehow deactivate the Standard "New" button?

 

Thanks again for your help!

 

 

Benajmin PirihBenajmin Pirih

Hey tsmith,

 

One other thing you can do is to redirect to a visualforce page, which only has the picklists that you need to pouplate.  Have the user fill out this info, create the record and then redirect to the edit page via the id.  This would be a two step process but would do what you want.  The advantage is that you have a single visualforce page to do your complex lookups and object creation.   The standard page for normal edits and updates.

 

  Hope that makes sense.  Also here is where to override a standard button..

 

http://www.salesforce.com/us/developer/docs/cookbook/Content/vf_override_button.htm

 

Good Luck..  Benjamin Pirih

tggagnetggagne

I'm trying to recreate what you did in a simple button.

 

By looking at the URL of the regular page, I was able to figure out what I needed for the other lookup field.

 

In the code below, the parent object is Feedback, and the child is Feedback_Effort.

 

/{!$ObjectType.Feedback_Effort__c}/e?CF00N60000002KxIS={!Feedback__c.Iteration__c}&CF00N60000002KxIS_lkid={!Feedback__c.IterationId__c}&CF00N60000002KxHy={!Feedback__c.Name}&CF00N60000002KxHy_lkid={!Feedback__c.Id}&saveURL=%2Fapex%2FFeedbackTabbed%3Fid%3D{!Feedback__c.Id}%26srPos%3D0%26srKp%3Da0b%26sfdc.override%3D1&retURL=%2Fapex%2FFeedbackTabbed%3Fid%3D{!Feedback__c.Id}%26srPos%3D0%26srKp%3Da0b%26sfdc.override%3D1

 

I'd like to trim that URL even more.  Actually, what I'd like to figure out his how to get rid of the hard-coded field IDs.  I think both the saveURL and retURL could be short-handed as {!$CurrentPage.URL}, but I may have to URLENCODE it.

tggagnetggagne
I just gave the $CurrentPage.URL a shot, but apparently that merge field isn't available inside the button. Too bad.