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
JuansaJuansa 

Copying account email into opportunity custom email field

I would like to copy the email address I have in the account to a custom email field I created in the opportunity associated with that account. I need a email field in the opportunity in order to notify via email after an approval proces has been approved. If this email field doesn´t exist I can´t send an email to the account. Is there a way with appex code to automate this copying and pasting??

 

Thanks!

bob_buzzardbob_buzzard

You shouldn't need to use Apex to do this.  You can create a workflow field update that updates the email field on the opportunity with the information from the account.

Pradeep_NavatarPradeep_Navatar

In my opinion, this can be done by using formula field in the opportunity object. This field will be autopopulated from the Account object email field.

 

Hope this helps.                

TrueCloudTrueCloud

I agree with Pradeep. Using a formula field will always keep the data in sync.

bob_buzzardbob_buzzard

It does depend on what the data will be used for.  There's no email formula field and a text formula field may not be suitable (e.g. sending an email via workflow).

TrueCloudTrueCloud

 


bob_buzzard wrote:

It does depend on what the data will be used for.  There's no email formula field and a text formula field may not be suitable (e.g. sending an email via workflow).


Agreed. This may be clumsy but you can hide the formula field and create a workflow to populate the email field that is displayed on the page when the formula field is changed.

 

bob_buzzardbob_buzzard

I don't see the advantage of this - you'd have two fields - the formula field and an email field, plus a workflow that updates the email field from the formula field.    Updating via workflow from the account object removes the need for the formula field.

TrueCloudTrueCloud

 


bob_buzzard wrote:

I don't see the advantage of this - you'd have two fields - the formula field and an email field, plus a workflow that updates the email field from the formula field.    Updating via workflow from the account object removes the need for the formula field.


To my knowledge I thought you cannot populate the field on the current object with a value from other object without using an Apex Trigger. For example if you want to have email address from the account page on the contact record to send an email. You cannot use a formula field to send that email. Standard workflow on contact cannot retrieve data from the account's email field, and finally you will need a trigger to update the data on the contact record. The only reason one would do this, is to avoid creating a trigger and still achieve the same functionality. Bob I absolutely agree that it is not best practice to do so.

 

bob_buzzardbob_buzzard

For the sake of completeness, it is possible to pull information through from the account to the opportunity via a workflow field update as I implemented this on my dev org prior to responding to this thread.  I think this is a special case though, as the help indicates that this isn't usually allowed for standard objects.

TrueCloudTrueCloud

Bob, that's great news. I see that on my dev account but not on production org on na3 or na7 servers. I believe this may just be available in the dev org for right now, but this feature will be great as it will eliminate the need for triggers in such situations.

 

Just to clarify, you are still not able to pull data from custom lookup field on a custom object. Similar to Account and Opportunity that you described. Is that correct?

 

Thanks for your help.

 

Rupesh

bob_buzzardbob_buzzard

I haven't checked for a while, but the last time I went this route, the help was correct, in that if it was a custom-custom master-detail then cross object was available, otherwise not.

TrueCloudTrueCloud

Thanks Bob, this is helpful.

sfdc newbiesfdc newbie

how to create a workflow field update that updates the email field on the opportunity with the information from the account. Please update its a bit urgent in detail as iam using person accounts.