I am beginning to look at using a Lightning Component to quick create records, I have been able to get quite far but have got a little stuck when trying to set the record type id of the destination record (it's a case and we have 15+ record types and I want to be able to set it alongside a lot of other predefined field values).
This is what I have got so far:
Apex Controller
public class QuickActionsController {
@AuraEnabled
//Get Record Type ID
public static Id getCaseRecordTypeID() {
Id CaseRTID = Schema.SObjectType.Case.getRecordTypeInfosByName().get('RTYPENAME').getRecordTypeId();
return CaseRTID;
}
}
Javascript Controller
createCase1: function (component) {
//Get Record Type Id
var CaseRecordTypeID = component.get("c.CaseRecordTypeID ");
var createRecordEvent = $A.get('e.force:createRecord');
if ( createRecordEvent ) {
createRecordEvent.setParams({
'entityApiName': 'Case',
'recordTypeId': CaseRecordTypeID ,
});
createRecordEvent.fire();
} else {
/* Create Record Event is not supported */
alert("Case creation not supported");
}
},...
This is my first lightning component, trying to make a quick actions menu to let users create records with fewer clicks/fields etc.
Sorry edit, the error states:
Error on parameter recordTypeId: java://java.lang.String
CaseRecordTypeID
declared on the component and when are you populating it? I don't see a call made to the aura method, so if that's done somewhere else? You may like to provide some more code from your component to be able to get some details here. – Jayant Das Aug 14 '18 at 15:06