How can I get the ID of a record being inserted with force:recordData?

4 Answers 4


The recordId property will be populated with the ID of the new record once it's created.

The solution is not hard to find, it's here.


Bind a record Id to the object, and you should be able to get it back out:

<aura:attribute name="recordId" type="Id" />
<force:recordData recordId="{!v.recordId}" ...
<aura:handler name="change" value="{!v.recordId}" action="{!c.recordSaved}" />

Or, you can get the value after force:recordSaveSuccess from the recordId attribute:

<force:recordData aura:id="recordData" ...

var recordData = component.find("recordData").get("v.recordId");

When you call the saveRecord method on the recordData component from javascript...

createNewExam : function(component, event, helper){
    component.find("ClonedExamCreator").saveRecord(function(saveResult) {

it is given an object of type RecordSaveResult as a callback. From this object get simply use recordID attribute.

let newExamID = saveResult.recordId;

saveResult.recordId is correct; state -> SUCCESS recordId -> a23O00000012YREIA2 error -> undefined entityApiName -> OrderInfo__c entityLabel -> OrderInfo action -> SecureObject: [object Object]{ key: {"namespace":"c"} }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .