Contents
- 1 When to use pre populate field values in Lightning?
- 2 When to use event preventDefault in Lightning recordform?
- 3 What can Lightning Data Service do for You?
- 4 How to create pre populated records with lightning recordeditform?
- 5 When do I need to create a pre populated record?
- 6 Are there pre populate fields in Salesforce Docs?
When to use pre populate field values in Lightning?
Pre-populating fields would be a custom use case, and our doc gives general facts of how a recordEditForm works. FYI, my use case was pre-populating field values when laoding a recordForm as well. (more specifically, a lookup field, however text fields were also raised in the context of the case). You should be able to do this with an action.
When to use event preventDefault in Lightning recordform?
There’s an excellent blog by Peter Knolle that addressed Lightning recordEditForm, but a lot of it seems to be working with recordForm as well. Basically, he shows you how to use event.preventDefault () during the onsubmit action. In this example he overrides the standard submit action and then populated/overwrites particular field values.
Can you use url hacks in lightning experience?
With Lightning Experience, we can’t use url hacks anymore. I’m fine with that, as this was not a supported solution. However, behind this technical hack was a business need: pre-populate field on record creation, often with different values depending on where you’re coming from.
What can Lightning Data Service do for You?
For code use cases, Lightning Data Service allows developers writing custom Lightning Components creating new records to pass in default field values.
How to create pre populated records with lightning recordeditform?
If you want to do this in a Lightning Component while using lightning:recordEditForm, you could do it the next way: As you can see, I am using some SLDS styles to show a static text for Description field. You could use an attribute instead and set it from the controller with the value you want to pre-populate.
How to pre populate a record in JavaScript?
You could use an attribute instead and set it from the controller with the value you want to pre-populate. What we are doing is to intercept the event, and set a value for the Description field, which by default was not included in the Javascript object.
When do I need to create a pre populated record?
A typical use case when creating records is to populate some fields in advance, and then let the user fill in the rest of required fields. Let’s say that we want to create account records, having a pre-populated description, like this:
Are there pre populate fields in Salesforce Docs?
Currently, the doc does not mention anything about pre-populating fields. Like any other salesforce doc, it outlines facts, and customizations depend on the person developing the solution. Your use case is a customization.