You need to sign in to do that
Don't have an account?
customDev
Automatically populate fields on opportunity from Account
Hi,
We need to automatically populate certain fields on an Opportunity from the corresponding account when an Account is selected on an opportunity. This is a one time population only at the time of the opportunity creation. Am looking for the best way to do this.
The fields are available on the Account.
Thanks
For me tooo its the same required
There's a LookUp field of Contact in Custom Object
so when i select contact , i want the contact address to be populated into Custom Object 's Address field (one time migration)
I think only way possible is use of Integration Stuff
figured it out, may not be the best way to do this but it works,
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>Opportunity: {!Opportunity_Name}</title>
<link href="/dCSS/Theme2/default/common.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" >
<link href="/dCSS/Theme2/default/custom.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" >
<link href="/css/assistive.css" type="text/css" media="aural,braille,embossed" rel="stylesheet" >
<link rel="shortcut icon" href="https://www.salesforce.com/favicon.ico">
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>
<script language="javascript">
var accountId="{!Account_ID}";
//Initiate the script
function initApp()
{
sforceClient.init("{!API_Session_ID}","{!API_Partner_Server_URL_70}"); //login to salesfroce using session Id and Server Url
updateMyField();
}
function updateMyField()
{
try
{
getAccountMyField();//Query Account Information
}
catch(e){}
}
//This method retrieves the information from the account
function getAccountMyField()
{
sforceClient.Query("Select my_field from Account where Id ='" + accountId + "'",insertOpportunityMyField);
}
//This method sets the information on the opportunity
function insertOpportunityMyField(qrAccount)
{
var strMyField;
if(qrAccount!=null && qrAccount.records.length>0)
{
for(i=0;i<qrAccount.records.length;i++)
{
strMyField = qrAccount.records[i].get("my_field");
}
}
else{
strMyField="";
}
var opportunity = new Sforce.Dynabean("opportunity");
opportunity.set("Id","{!Opportunity_ID}");
opportunity.set("my_field",strMyField);
var sr = sforceClient.Update([opportunity])[0];
if (sr.success == true) {
alert("Update was successful...");
} else {
alert("Update failed: " + sr.errors[0].message);
}
top.location.replace("/{!Opportunity_ID}/e?retURL=/{!Opportunity_ID}&save=1");
}
</script>
</head>
<body onLoad="javascript:initApp()";>
</body>
</html>
A decent way to handle that is to create a custom link (or even better, an image hyperlink field made to look like a button) on the Account page.
Call it "Opportunity Quick-Create" or something like that, and simply go to the opportunity creation URL using merge fields to define the info you want to populate (e.g. [new opp url]&Opp_Industry__c={!Acc_Industry__c})
Then the users have two choices... create an opp from scratch... or create an opp with your quick link and have some of the work done for them. No one can say no to that.
Thanks Michael,
Part of the requirement was that the users have a single creation process. We have actually done this through external customization and looks like APEX can do that. We were trying to see if it could be done with minimal impact to users in terms of training/process.