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
SeanziesSeanzies 

On a custom object, when you select an account the account address fills in a text area

I have a custom object i created.

It has an Account(Master Detail) field

It also has a Text Area field.

 

When a user selects an Account I want to fill in the Shipping Address of the Account selected into the Text Area field?

 

Would I use a VLookup() or something else? how would I do that?

Best Answer chosen by Admin (Salesforce Developers) 
SeanziesSeanzies

Dude, your a lifesaver!

Thanks

 

All Answers

mstev45mstev45

This can be done using a workflow rule.

 

Create a workflow and select it for when the criteria is met. Then set the criteria to when 'Your Field' equals Null.

Next create a immediate workflow action with a field update. Use a formula to set the new value:

Account__r.BillingStreet & ", " & Account__r.BillingCity & ", " & Account__r.BillingState & ", " & Account__r.BillingPostalCode & ", " & Account__r.BillingCountry.

 

So when you create the custom record and leave that field blank then it will automatically update the field with the accounts billing address.

 

Hope this solves the problem

 

Matt

SeanziesSeanzies

Thanks Matt,

 

How does it know what account to look up?  Where is it referencing the "Account"

field on the custom object to look up the address?

 

Also would the address only be populated after the record was saved?

I am looking for it to populate immediately after an account was selected which is why

I was thinking a formula.

 

Any suggestions of where i could read more up on this besides the help?

mstev45mstev45

Yes you could also use a formula field. Just create a new text type formula field. When it comes to the section for editing the formula use the advanced formular editor. Then click on the insert field and click on the name of your custom object in the left hand list, then in the list next to it click on Account > .  You can now access any of the fields on the account page, so you would select the shipping fields, so it will look something like this:

 

Account__r.BillingCity + "," + Account__r.BillingCountry

 

Matt

SeanziesSeanzies

Dude, your a lifesaver!

Thanks

 

This was selected as the best answer
SeanziesSeanzies

One more question.

What I am trying to accomplish is similar to the following.

 

Click Contacts Tab

Create new contact

Select the Account

   Once the account has been selected, it auto populates the Mailing Street, City, ST and Zip fields but allows the user to type over those fields in they choose and then hit save.

 

How would I try to accomplish this?  With you help I can get the address fields to populate based off of the account selected but there read only and I want to be able to edit them. 

 

I did try creating another text field that the default value is the value of the formula text field, however it doesn't get updated when the account is selected because the default value is nothing because the address wasn't updated. 

 

Make sense?

 

mstev45mstev45

This can be done by simply creating the new contact through the account page and not going to the contact tab. i.e you find the account you want to add the contact to, select the account, click new contact on the account related list. This will load the new contact screen and should pull through the info from the fields on the account page and it can also be edited.

Hopefully this will sort the problem.

 

Matt

rpr2rpr2

Seanzies,

 

If I understand what you are wanting to do, there will actually be a couple of steps involved.  You will need to create an s-control that copies the address from the account and then override the new button on your custom object with the s-control.  This will give you the ability to have the address default when creating a new record and be able to edit it if necessary before saving it.  The formula option that has been suggested is simpler to do but does not let you edit the address.

 

Since you asked to be directed to reading material, I would suggest starting with online help, and search for:  "Useful S-Controls".  Part of your task will be identifying the address fields that you want to copy from the account (billing or shipping).  A very good resource for this is on an article on the Decoding Salesforce blog called How to obtain a field ID

 

Rhonda

Message Edited by rpr2 on 03-22-2009 10:39 AM