Add Contact button- Can't get URL redirect to work

  • 1
  • Question
  • Updated 2 years ago
  • Answered
I am trying to great a Global Action button that will redirect my users to the standard create new contact page in salesforce.  I can get the page to pull up fine, but I can't get the AccountID to pass into the Account field.

Here is my redirect URL:
/setup/ui/recordtypeselect.jsp?ent=Contact&retURL=%2F{{{$Model.Contact.data.AccountId}}}&save_new_url=%2F003%2Fe%3FretURL%3D%252F{{{$Model.Contact.data.AccountId}}}%26accid%3D{{{$Model.Contact.data.AccountId}}}

Any idea what could be wrong?
Photo of Stephen Chilcoat

Stephen Chilcoat

  • 732 Points 500 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
you need to indicate the row number. If you only have one record in the model (like a detail page), then it is row 0. Modify your merges like this:
{{{$Model.Contact.data.0.AccountId}}}
Photo of Stephen Chilcoat

Stephen Chilcoat

  • 732 Points 500 badge 2x thumb
Thanks Raymond.  That works except in the case where my contact model is empty (i.e. there aren't any contacts already associated with the account).  Any ideas for that?  
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
If you aren't populating that parameter anyway, you should be able to just drop it out of the URL.
Photo of Stephen Chilcoat

Stephen Chilcoat

  • 732 Points 500 badge 2x thumb
I figured it out.  Had to run this as a run multiple actions button and re-query the model before my redirect.