Find your content:

Search form

You are here

Custom "New Contact" button on Account detail page

 
Share

I've a created a custom button on Contact object and added this to Contact Related-list on Account's Page layout. I want this to depict same functionality as standard "New Contact" button does. If use following code then it doesn't pre-populate the Account lookup field.

{!$Action.Contact.New}

Is there any way to do so?


Attribution to: doga

Possible Suggestion/Solution #1

Try using

window.open('{!URLFOR($Action.Contact.NewContact, Contact.Id )}');

Update : try this : click on inspect element on the lookup button and you can find Id of the lookup as con4_lkwgt (I would assume this to be same since its a standard field) and click on the account name field and get the ID as con4

/003/e?con4={!Account.Name}&con4_lkwgt={!Account.Id}&&retURL=/{!Account.Id}

Refer this blog for more insight on how to override the buttons http://raydehler.com/cloud/clod/salesforce-url-hacking-to-prepopulate-fields-on-a-standard-page-layout.html


Attribution to: Rao

Possible Suggestion/Solution #2

You'll have to look at the field names. The list of names for standard fields is for example here: http://phollaio.tumblr.com/post/22058016777/how-to-obtain-a-field-id, for custom fields it's usually the field Id when viewed in setup (in case of doubt use Firebug or similar tool to inspect the HTML).

Something like this should give you the general idea how to start:

/003/e?con4_lkid={!Account.Id}&name_firstcon2=Hello&name_lastcon2=StackOverflow

It's up to you if you want to write full URL yourself or do you prefer to read a bit more about URLFOR function (quite powerful). Generally speaking this will populate Account nicely if you've fired it from rel. list under Account - from other places it is likely to return empty string so you might have to use CASE() or similar to make it more generic (depends on when do you plan to use the button).


Attribution to: eyescream
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4581

My Block Status

My Block Content