I have a custom visualforce page that displays some account info. The page has a "New Contact" button that does this:


This works great. However, I would like for the Account lookup field on the new contact page to be pre-populated with the Account the user is viewing. Is this possible in SF1?

3 Answers 3


From the Summer '17 Release Notes - Prepopulate Fields on a Record Create Panel

Speed up record creation with prepopulated field values. The sforce.one.createRecord function now includes defaultFieldValues (optional) so you can define fields on a record create panel, including fields not displayed on the panel. This change applies to Lightning Experience and the Salesforce1 mobile browser app.

Users must have create access to prepopulated fields. Errors during saving that are caused by field access limitations do not display error messages.

So defaultFieldValues will become the official supported mechanism to preset fields with sforce.one.createRecord.


The kind of URL hacking that works in Salesforce will not work in Salesforce1. In order to do pre-fill field values in Salesforce1, you would need another Visualforce page. The new page would be passed the ID of the current account as a parameter and use that to set class fields as needed.

  • He can't add any code to the button to pass the AccountID as the Related Account field in SF1?
    – crmprogdev
    Jan 30, 2015 at 20:07
  • 1
    I've seen it said in various places (can't find any just now) that old-style Salesforce URL hacking will not work in Salesforce1. Certainly my limited attempts at it have not worked. If there is a way to do this that doesn't require the creation of a VF page, I'd love to know what it is.
    – Jagular
    Jan 30, 2015 at 20:23

@DanielBallinger's answer is correct. I just want to extend it by an example and show you the most likely pitfalls trying to make it work. Plain and simple, you can use it like this one-liner:

    AccountId : "0010Y000007uaVI",  

Caution 1:

The this feature from Summer'17 works only if you put your Visualforce Page to API v40.0 or higher.

Caution 2:

Objectnames and Fieldnames are CASE-SENSITiVE! So contact is not Contact and only Contact is correct

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .