I am try to call lightning component from VF Page and trying to call force:createRecord from lightning component. but getting below error message:
This page has an error. You might just need to refresh it. Action failed: c:workLineItem$controller$doInit [Cannot read property 'setParams' of undefined] Failing descriptor: {c:workLineItem$controller$doInit}
Below is code snipped
VF Page
<apex:page>
<apex:includeLightning />
<div id="lightning" />
<script>
$Lightning.use("c:workLineItemApp", function() {
$Lightning.createComponent("c:workLineItem",
{ label : "" },
"lightning",
function(cmp) {
});
});
</script>
</apex:page>
Lightning App
<aura:application access="GLOBAL" extends="ltng:outApp">
<aura:dependency resource="c:workLineItem"/>
</aura:application>
MarkUp
<aura:component implements="force:appHostable" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
</aura:component>
Controller
({
doInit : function(component, event, helper) {
console.log("WorkLineItemController.doInit: Entered");
var createNewRecord = $A.get("e.force:createRecord");
createNewRecord.setParams({
'entityApiName': 'WorkOrderLineItem'
});
createNewRecord.fire();
console.log("WorkLineItemController.doInit: Exit");
}
})