I have a lightning custom page and I need to include a New button to create a new record.
How to do this.
Best Answer
Create a new record in Lightning
You may want to opens the page to create a new record for the
specified entityApiName, for example, “Account” or
“myNamespace__MyObject__c”.
To display the record create page for an object, set the object name
on the entityApiName parameter and fire the event. recordTypeId is
optional and, if provided, specifies the record type for the created
object. This example displays the record create panel for contacts.
You can't. Javascript buttons aren't supported by Lightning. Lightning pages are single page applications. Most everything in Lightning is done using Actions.
Custom buttons that call JavaScript aren’t supported in Lightning Experience.
UPDATE - Use the Lightning Experience Configuration Converter recreates your org’s JavaScript buttons as Lightning components, quick actions, or other solutions — all without touching your original buttons.
Best Answer
Create a new record in Lightning
Button
Controller
For Reference