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
kmadminkmadmin 

Mapping Fields Between a Standard and a Custom Object using Visualforce

Hi,

 

I have a need to copy data from a standard object (Opportunity) to a related custom object (Proposal) when "New Proposal" button is clicked on the Proposal related list on the Opportunity detail page.

 

I think my only two options are Visualforce page and s-control. Considering s-controls will be retiring soon, I think my only option is Visualforce. However, I am a Visualforce novice and want to know the following:

 

Can I create a visualforce page without any user interface by overriding "New" button on the custom object (Proposal) that will allow me to take data from standard object (Opportunity) fields and copy it to related custom object (Proposal) fields?

 

If the answer is Yes, can you get me started with some details or a code sample on how to do this?

 

Thanks.

mtbclimbermtbclimber

What do you mean by "without any user interface"? 

 

You can override the new action for proposal or create a custom button on opportunity but in either case your user is going to end up on a visualforce page. Any attempt to redirect back to the standard new/edit form is going to lose the info you wanted to default.  If you are OK with going to a Visualforce page this example may be helpful:

 

http://wiki.developerforce.com/index.php/Visualforce_Quote2PDF

 

If you are not then I don't think what you are looking for can be achieved using any supported technology.

kmadminkmadmin

When I say "Without any user interface", I mean a pass-through page.

 

What I don't want to do is to design the custom object deetail page. Instead, just use the standard detail page.

 

Here is what I am visualizing:

 

1) On opportunties detail page I have a related section called "Proposals" that refers to the related custom object.

 

2) I want to override the "New Proposal" button on Opportunity detail page.

 

3) I have multiple record types for the Proposal custom object so when the "New Proposal" button is clicked, the user will be asked to select a record type.

 

4) When the user selects a record type, the custom object detail page for that record type is displayed.

 

5) The custom object detail page have some fields that are exactly the same as some custom fields I have on the opportunity detail page. However, I need to copy their values to the custom object as the idea is they may be modified or left intact.

 

6) When the custom object detail page is displayed, I want to pre-fill fields that are also available in related opportunity.

 

As you can see, I have two challenges:

 

I) There are multiple record types so when clicking "New Proposal", I need to let user select a record type.

 

II) Based on the record type, when the custom object detail page is displayed I need to copy fields from Opportunity to the custom object detail page.

 

Is there any way to achieve what I want? I may be able to get away with multiple record types but is there any way to utilize the standard detail page for custom object instead of writing a visualforce page that mimics the standard form?

 

Thanks.

JimRaeJimRae

Here is an example that I found that does what you are looking for.  I would surmise that it is not officially supported, but it does appear to work.

 

http://salesforceexperts.blogspot.com/2009/07/standard-newedit-page-vs-your.html

 

What it basically does is read data from your calling page (in your case Opportunity) and hold them in memory in the VF Controller, then creates a URL querystring  that redirects to a standard page, with fields populated.

The part that is not supported is using the field id's on the standard page, technically, that is no longer supported. In the past (s-control days) this was a recommended practice by SFDC, based on some old PPTs that I have seen.

 

This site: http://salesforce.phollaio.com/tag/urls/ is also a great reference for how to decode the URLs.

 

Good Luck.

kmadminkmadmin

Jim,

 

Thanks for your help. I knew about looking up field IDs from the HTML source and using URL query string to populate them. However, I know that I am going to run into the URL size limitation as I have to copy about 25 fields and some of the are long text areas.

MVJMVJ

Try this:

 

1.  Create a VF page based upon the opportunity

2.  You can pass the Opportunity ID to the page.

3.  You can then run a SOQL query to get the fields you want from the opportunity object and populate the data you need on the VF page.

 

 

 

JimRaeJimRae

If that is your scenario, and you need all of those fields, you are probably going to have to create a custom VF page to create your Proposal object.

Since you have multiple record types, this will be even more complex, you will likely need to add an interface page that asks the user which Record type (or determines which should be used programatically), and then redirects to the appropriate "New Proposal" Page.