I'm trying to use the force:recordData to clone a record with some fields changed in the backend. I am able to retrieve it to the front-end. But unfortunately it seems force:recordData doesn't refresh my front-end, noticed the LayoutType in it's specification is used only for querying.

    <force:recordData aura:id="clonnedRec"
                      targetFields ="{!v.simpleNewOpp}" 

Is there a proper workaround to load the standard layout with force:recordData like Salesforce Lightning default Create/Clone/Edit actions do?

Appreciate any help. Thanks.


force:recordData is for accessing record data. It does not display data.

If you want to display record data use one of these tags:

  1. lightning:recordForm, the simplest way but least configurable
  2. lightning:recordViewForm, or
  3. lightning:recordEditForm

(2) and (3) allow you to control where each form appears. Eg you can create an n-column layout or tabular layout, whatever you like. (1) applies the layout for you making its usage much simpler.

These three tags do a lot of heavy lifting to display the data correctly. For example, they select the appropriate component to visualize or edit the field based on its field type.

  • Thanks for your reply @Kevin, None of these seem to support pre-edit the object fields, or change field values in the component. We need this functionality, so unfortunately these 3 components seem not helpful yet. Cheers! – Pasan Eeriyagama Jun 12 '18 at 23:23
  • By "object fields" do you mean the record field values? If so then look at the onload event fired by these components. Further, you can use lightning:inputField to specify arbitrary default values as you build your form with lightning:recordEditForm. – Kevin Venkiteswaran Jun 12 '18 at 23:28
  • I agree with you that we can use onload event but in that event if I need to change some record field values, lightning:recordEditForm seems not exposing any record for developers to access and modify content(record field values), for example something like component.set('v.sobject',ObjwithChangedFieldVals) or any other mechanism. – Pasan Eeriyagama Jun 12 '18 at 23:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.