+ Start a Discussion
fredsmithsonfredsmithson 

account to contact info

help

 

I am trying to self-populate information on an account from its contact so that I don't have to double entry data and a user can quickly see key primary contact data at the account level

 

for example - i have a contact that is billing so in the account record - I also want to show this to make the devlelopment simple I added a lookup function so that I pick up the relative contact - I then used workflow rules to self-populate billing phone number, billing, email, etc.

 

I have a problem now that I used so many references to post on the account from the conatcts I get the following error:

 

ideally I would like just to have a checkbox on the contact record saying blling contact and at the account level it would pick up the appropriate contact - using the lookup with workflow rules is a fine workaround but I am finding out is limited.

 

any suggestions???

 

Error

You have reached the maximum number of 5 object references on Account

You must remove at least 1 relationship(s) in order to save this formula
Related objects referenced in this formula:
  • Billing_Name__r
Show SectionHide References
Formula NameFormula TypeRelated Object ReferenceLast Modified DateLast Modified By
Account
cleairng/operations fax 2Workflow Field UpdateClearing_Operations_Contact_2__r8/12/2009 3:18 PMFSmit
clearing firm email nameWorkflow Field UpdateClearing_Firm_Contact_Name__r8/12/2009 3:24 PMFSmit
clearing firm email updateWorkflow Field UpdateClearing_Firm_Contact_Name__r8/13/2009 11:08 AMFSmit
clearing firm phone numberWorkflow Field UpdateClearing_Firm_Contact_Name__r8/12/2009 3:20 PMFSmit
clearing firm phone number updateWorkflow Field UpdateClearing_Firm_Contact_Name__r8/12/2009 3:53 PMFSmit
clearing/operations phone 2Workflow Field UpdateClearing_Operations_Contact_2__r8/12/2009 3:17 PMFSmit
primary account email updateWorkflow Field UpdatePrimary_Contact_Name__r8/12/2009 11:34 AMFSmit
primary account phone updateWorkflow Field UpdatePrimary_Contact_Name__r8/12/2009 2:00 PMFSmit
update clearing operations 2 emailWorkflow Field UpdateClearing_Operations_Contact_2__r8/12/2009 3:17 PMFSmit
update clearing operations faxWorkflow Field UpdateBackOfficeContact__r8/12/2009 3:15 PMFSmit
update clearing/ooperations phone numberWorkflow Field UpdateBackOfficeContact__r8/12/2009 3:15 PMFSmit
update clearing/operations emailWorkflow Field UpdateBackOfficeContact__r8/12/2009 3:13 PMFSmit
update primary acct fax numberWorkflow Field UpdatePrimary_Contact_Name__r8/12/2009 2:16 PMFSmit
update primary acct titleWorkflow Field UpdatePrimary_Contact_Name__r8/12/2009 2:16 PMFSmit
update primary phone numberWorkflow Field Update

sgoldberRHsgoldberRH
Make them text fields, and populate them via a trigger. 
fredsmithsonfredsmithson
thanks good idea -- I have never tried triggers - how do they work????
sgoldberRHsgoldberRH

It is a form of Apex custom code. This wouldn't be a very complicated trigger, but if you haven't created one before it may be a bit complex. I found this board very helpful though for learning. Also here is a link below to a start guide. 

 

 

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_qs_HelloWorld.htm

 

fredsmithsonfredsmithson

okay I got the example to work

 

I tried to modify to get the trigger to work

 

but wasn't sure if I was referencing it correctly.  the idea here is in the lookup field like I do a formula - I used

 

billing name>  contact phone

 

a.Hello__c =  a.x2Billing_Name__r.Phone ;

 

but it keeps putting in nothing in the blank space.

 

I am trying to update the billing number as a test - when I have defined the billing name already via the lookup function.

 

there must be references on cross-referencing via lookups but didn't easily seem them on the board

 

thanks!

sgoldberRHsgoldberRH

can you copy and paste your entire code? It would be helpful. Also when pasting use the code icon up top between the striked through abc and the clipboard with a W icons.

 

 

fredsmithsonfredsmithson

this is the entire code its really simple:

 

 

// This class updates the Hello field on account records that are
// passed to it.
public class MyHelloWorld {

   public static void addHelloWorld(Account[] accs){

      for (Account a:accs){
         if (a.Hello__c != 'XX') {
            a.Hello__c =  a.x2Billing_Name__r.Phone ;
         }
      }
   }

 

 

as I mentioned I got the field name copied over from a "formula insert" when did a dummy insert field from my acount to cross object reference the field from contacts i

 

account> 2 billingname (a lookup)> phone

gives me the name x2Billing_name_r.phone - I had to put an "a." in front of it to get it to run...

but it doesn't run correctly - just leaves a blank spot in the field hello - even though - I do have a billing contact lookup name entered and that name has an associated phone number.

 

 

 

 

 

sgoldberRHsgoldberRH

This is code from a class... not a trigger.  Its probably not a good idea to try and use this code for your purposes. 

 

Yours should look something more like this 

trigger nameYourTriggerHere on Contact (before update) { for(Integer i=0;i<Trigger.new.size();i++){ // the field Role is something you would have to create to distinguish which type of contac this is //Trigger.new[i] is the contact record you are working with Account a = [select id, Clearing_Firm_Contact_Name__c from Account where id =: Trigger.new[i].Account AND Trigger.new[i].Role__c = 'Clearing Firm Contact'] // a. is the account Clearing_Firm_Contact_Name__c is the field you want to update a.Clearing_Firm_Contact_Name__c = Trigger.new[i].Name; update a; } }

 


 

 This will not work for you as is...but it will give you something better to play with then what you are working with. Make sure to create a Trigger not a Class.