Navigate to the new record page for any object. Optionally pre-populate fields with default values usingDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/trailheadapps/lwc-recipes/llms.txt
Use this file to discover all available pages before exploring further.
encodeDefaultFieldValues.
Source
force-app/main/default/lwc/navToNewRecord/navToNewRecord.jsforce-app/main/default/lwc/navToNewRecordWithDefaults/navToNewRecordWithDefaults.js
Basic Usage
With Default Field Values
NavigationMixin
Extend your component withNavigationMixin to access navigation capabilities:
PageReference
Set to
standard__objectPage for object pagesThe API name of the object (e.g., ‘Contact’, ‘Account’, ‘CustomObject__c’)
Set to
new to display the new record creation pageEncoded default field values. Use
encodeDefaultFieldValues() from lightning/pageReferenceUtils to encode an object of field name-value pairsDefault Field Values
UseencodeDefaultFieldValues to pre-populate form fields:
Key Features
- Navigate to new record creation forms
- Pre-populate fields with default values
- Supports all standard and custom objects
- Type-safe navigation with PageReference
