You will need at least SOME communication with the server, but at least you won't have to write any code yourself.
You can use the aura recordData
component (or even the lwc version if you want).
You would write something like this:
<aura:attribute name="obj" type="Object"/>
<aura:attribute name="simpleObj" type="Object"/>
<aura:attribute name="objError" type="String"/>
<force:recordData aura:id="objRecordLoader"
recordId="{!v.recordId}"
fields="Agent__c,CaseNumber__c"
targetRecord="{!v.obj}"
targetFields="{!v.simpleObj}"
targetError="{!v.objError}"
recordUpdated="{!c.handleRecordUpdated}"
/>
As soon as your recordId becomes filled (which I note has a typo in your code at the top - force:hasRecordI
is missing the D
, then your target fields will be come filled and you can then prefill your desired record.
However, you will need to wait until the record loads, so you would NOT use the invoke
method... which is ONLY for lwc components.
When handleRecordUpdated
is invoked, you would then fire the createRecordEvent
.
eg:
handleRecordUpdated : function(component, event, helper){
let calibrationID = component.get("v.recordId");
let createRecordEvent = $A.get("e.force:createRecord");
createRecordEvent.setParams({
"entityApiName": "QA_Review__c",
"defaultFieldValues": {
'QA_Calibration__c' : calibrationID,
'Agent__c': component.get("v.simpleObj.Agent__c"),
'Type__c': "Test",
'Case__c': component.get("v.simpleObj.CaseNumber__c")
}
});
createRecordEvent.fire();
}