Copy Account Address to New contact when Account is selected

  • 1
  • Question
  • Updated 4 years ago
  • Answered
I am trying to get my Skuid  new contact page to act more like the default salesforce page. In my Skuid page, I need to billing address to be copied to the contact when I select the account I want this contact to be related to. 


Thanks for your help.
Andy
Photo of Andy Chasin

Andy Chasin

  • 382 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
This forum post shows how to prepopulate Account ID in the new contact record.  

Moving Address information is a very simple extension of what is described in that post. 
Photo of Andy Chasin

Andy Chasin

  • 382 Points 250 badge 2x thumb
Rob,
I saw this one. This talks about creating a contact from the account page. I am creating a new contact from the 'Create New...' drop down on the left and I do not have the accid in the URL to use. I need to dynamically get the address when the related account is selected.

Does this make sense?

Thx
Andy
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
The first one of your actions needs to be "Activate and Set Value of Model Condition"  (Which requires you to have set up a filterable condition on the Current Account model.   The value passed should be {{AccountId}}  from the Contact model. 

Then with the condition set, the CurrentAccount model gets requeried, so it has the right data,  and you can move over data into the Contact model. 

You are so close.. 
Photo of Andy Chasin

Andy Chasin

  • 382 Points 250 badge 2x thumb
Rob,
Still not getting it.... Do you have few minutes to bring me the rest of the way home?
Andy
Photo of Andy Chasin

Andy Chasin

  • 382 Points 250 badge 2x thumb
Rob,
Getting closer. My problem now is what is the syntax to pass the street from the Current Account Model to the Contact model?? I can pass a static value using 'the update a filed on row(s)' action, so I know 'the activate and set value of Model Condition' works.

So Close I can taste it.

{{$Model.CurrentAccount.BillingStreet}} or {{$Model.CurrentAccount.data.0.BillingStreet}} ?????

Here is the model
     <model id="CurrentAccount" limit="20" query="true" createrowifnonefound="false" sobject="Account" doclone="" type="">         <fields>
            <field id="BillingAddress"/>
            <field id="BillingCity"/>
            <field id="BillingState"/>
            <field id="BillingStreet"/>
            <field id="BillingPostalCode"/>
         </fields>
         <conditions>
            <condition type="modelmerge" value="" field="Id" operator="=" mergefield="AccountId" novaluebehavior="deactivate" state="filterableoff" inactive="true" name="Id" model="Contact" enclosevalueinquotes="true"/>
         </conditions>
         <actions/>
      </model>
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
{{$Model.CurrentAccount.data.0.BillingStreet}}  should work so long as BillingStreet is the Account model and it has a value.
(Edited)
Photo of Andy Chasin

Andy Chasin

  • 382 Points 250 badge 2x thumb
Got it. After I activate the condition, I needed to query the model to get the data to pass.

Thx Pat and Rob!