I am trying to replace a URL button used in a list view in Classic to Lightning Compatible. I am trying to open a lightning component through URL that fires the create new page of the object with prepopulated values. The lightning component is like below
Component
<aura:component implements="lightning:isUrlAddressable" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>
Controller
({
doInit : function(component, event, helper){
var createRecordEvent = $A.get("e.force:createRecord");
var record_Id = 'XXXYYYZZZZ';
var alert = 'Test';
createRecordEvent.setParams({
"entityApiName": "Inventory__c",
'recordTypeId': record_Id,
"defaultFieldValues": {
'alert__c' : alert
}
});
createRecordEvent.fire();
}
})
I created the URL button and have the URL like /lightning/cmp/c__createInventory
where createInventory is the lightning component name, when clicking on the button it navigates to the blue screen nothing is happening no errors / no create new page getting fired. Can anyone please help me here what I am missing.