enter image description hereWe are migrating our code to lightning. We have a javascript button in case object which opens up a custom object create new record page with pre-populated values from case. How can i do the same thing in lightning?.

We tried multiple ways but the values are not getting populated. The custom object got 2 lookup fields for case and contact. Which i need to pre-populate.


field IDs we have saved in the custom setting in the above.


You would typically create a Quick Action that calls a controller method, which in turn fires off a force:createRecord event. The example in the documentation provides the necessary code:

var createAcountContactEvent = $A.get("e.force:createRecord");
    "entityApiName": "Contact",
    "defaultFieldValues": {
        'Phone' : '415-240-6590',
        'AccountId' : '001xxxxxxxxxxxxxxx'

All you need to do is create a new component that serves as a Quick Action to initialize your component, then fire off this event. The platform will take care of the rest for you.

Note that you can now use the standard API names, instead of maintaining custom settings that keep track of the field ID. You may need to combine this with force:recordData in order to bring in current record information.

There's other (recent) examples of this if you just search for the term here on the Salesforce StackExchange.

  • Thanks for the idea. But in the org case Feed is enabled and hence the quick action buttons come below the feed. Client wants the buttons only in the header. Is there any way to move the quick action buttons to header? – bksfdc Dec 21 '17 at 5:58
  • @bksfdc Not sure why I didn't see your message before, but I'd recommend firing off a force:closeQuickAction to get rid of the action itself, since it's not needed. – sfdcfox Dec 24 '17 at 7:34
  • i dont think i have got point. Can you please give bit more detail – bksfdc Dec 27 '17 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.