I’m using lightning:recordForm to display create view for a custom sObject. It works as expected, but I cannot find a way to pre-populate some of the fields for create view, e.g. lookups.
Documentation says that I can use onload action to modify loading behaviour, but it doesn’t specify how.
I would really like to use this component, instead of creating a custom component based on the lightning:recordEditForm, with dynamically created and populate input fields.
So basically the question is: is there a way to pre-set some of the field values upon object creation through lightning:recordForm?
After an extensive discussion with Salesforce support:
recordForm may not work with your use case, and the better approach here would be to use recordEditForm. This is only after discussing this with my team in our internal forum.
You had a concern that why it doesn’t work with recordForm- to which I
have mentioned that it will not work with recordForm, and would be
better to use recordEditForm.
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.
I am absolutely not questioning your right to put forward this
question. In fact, I understand why do you have this question in the
first place. However, what matters here is you having a solution – and
recordEditForm would be your best bet here. R&D will not consider
changing the doc, as there is nothing mentioned about pre-populating
fields there. Pre-populating fields would be a custom use case, and
our doc gives general facts of how a recordEditForm works.
In a nutshell –>
This is not supported and you will want to use
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).
Case Number for Reference Purposes #19884436