Pre-populating fields at record creation in Lightning Experience

For declarative use cases, Salesforce PM Kamyar Seradjfar recently did a blog series on removing javascript hacks for Lightning Experience. His suggestion for this use case is to use Quick Actions with pre-populated fields by value or formula: https://developer.salesforce.com/blogs/developer-relations/2016/09/take-the-first-steps-ways-you-can-replace-javascript-buttons.html

For code use cases, Lightning Data Service allows developers writing custom Lightning Components creating new records to pass in default field values.

See the defaultFieldValues param in the createRecords() method, documented here: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/data_service_create_record.htm (Lightning Data Service is in Developer Preview for Winter '17, which means the force:recordPreview component may only be used in Developer Edition orgs.)

Edited to add: there is a new Trailhead module on this topic: Lightning Alternatives to JavaScript Buttons


The Spring '20 release brought the URL hack for prepopulating field values to Lightning! So you can once again achieve this with custom buttons (not Javascript buttons) and links much like we used to in Classic.

Spring '20 release note: Navigate to a Record's Create Page with Default Field Values

Where: This change applies to Lightning Experience in all editions. This change doesn’t apply to Lightning Out, Lightning communities, or the Salesforce mobile app.

How: To construct a custom button or link that launches a new record with prepopulated field values, use this sample formula:

/lightning/o/Account/new?defaultFieldValues=
    Name={!URLENCODE(Account.Name)},
    OwnerId={!Account.OwnerId},
    AccountNumber={!Account.AccountNumber},
    NumberOfEmployees=35000,
    CustomCheckbox__c={!IF(Account.SomeCheckbox__c, true, false)}