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
TanfranciscoTanfrancisco 

Loading Data from contact into opportunity using s-control

Can you create an S-control that allows you to auto-populate contact information into an opportunity?  I need to load the additional contact fields like company name, address, phone, email, etc and want to avoid having to retype the information each time that I link a contact to an opportunity.
 
Can anyone point me to some code that I can use?
 
Tanfrancisco
dreamhomescrmdreamhomescrm
Hello,

This is a quick S-control with javascript that we developed that carries information to one tab or another based on the user clicking a button. It may serve your purpose.

This example prevents a new opp from being created without populating the Mailing Address fields first and then it carries over the Lead source information.

The trick to carry over the data is finding out the associated field names and calling on the correctly. You can find their by viewing the html source code for the page in question.

****************************************

Label Create New Opportunity
Name Force_Address_Completion Display Type Detail Page Button
Behavior Execute JavaScript

OnClick JavaScript var themailingstreet = "{!Contact.MailingStreet}";
var themailingcity = "{!Contact.MailingCity}";
var themailingstate = "{!Contact.MailingState}";
var themailingzip= "{!Contact.MailingPostalCode}";
var themailingcountry = "{!Contact.MailingCountry}";
var theaddress = themailingstreet + themailingcity + themailingstate +themailingzip + themailingcountry;
var theaddresslength = theaddress.length;

if(theaddresslength==0)
{alert('Please fill in the complete Mailing Address before creating an Opportunity.');}
else
{navigateToUrl('/006/e?retURL=%{!Contact.Id}&accid={!Account.Id}&conid={!Contact.Id}&00N20000000uv1a={!Contact.Search_Term__c}&opp6={!Contact.Lead_Source__c}&00N20000000uvro={!Contact.Product_Requested_from_the_web__c}&00N20000000uvrr={!Contact.Customer_Action__c}&00N20000000vM0y={!Contact.X1st_Date_Customer_Action__c}&00N20000000vM0o={!Contact.Country_of_Interest__c}&00N20000000vM0t={!Contact.In_bound_DHWW_website__c}');}

*******************************************

Good luck!

Paul
Greg HGreg H

Here is an example which should illustrate an entirely different way to do what your asking.

Code:

HYPERLINK("006/e?retURL=%2F"&Id&"&opp3="&FirstName&"%20"&LastName&"%20-%20Lots%20of%20Widgets","Populate New Opportuniy with Contact Info","_self")

 

In this sample, I am creating a new custom formula field on the contact record and placing this code as the formula.  What this will do is, when clicked from the contact record, create a new opportunity and place the contact's first and last name in the name of the opportunity with the text "Lots of Widgets".  So the full name of the opportunity will read "Firstname Lastname - Lots of Widgets".

This is a rather simplified example but it should get you started,
-greg
TanfranciscoTanfrancisco
Thanks much for the information.  I will code it up and test on my application.
sfdcfoxsfdcfox
And yet another way to do that:

Code:
window.top.location = '{!URLFOR($Action.Opportunity.New,null,[retURL=Contact.Id,accid=Account.Id,conid=Contact.Id,00N20000000uv1a=Contact.Search_Term__c,opp6=Contact.Lead_Source__c,00N20000000uvro=Contact.Product_Requested_from_the_web__c,00N20000000uvrr=Contact.Customer_Action__c,00N20000000vM0y=Contact.X1st_Date_Customer_Action__c,00N20000000vM0o=Contact.Country_of_Interest__c,00N20000000vM0t=Contact.In_bound_DHWW_website__c],true)}'
This code can be made as a custom button/link on the contact (Setup \ App Setup \ Customize \ Contacts \ Buttons and Links), using the Execute JavaScript Behavior, and the Content Source as OnClick JavaScript.

~ sfdcfox ~