I'm new with all of this so please be gentle :) So...I've got a lightning:recordForm that I'm using to create a new record. After I hit save I would like to be redirected to the newly created record.
Here's my cmp:
<aura:component controller="text_card_r" implements="force:hasRecordId,force:appHostable,flexipage:availableForAllPageTypes">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="projects" type="List"/>
<aura:attribute name="employees" type="List"/>
<aura:attribute name="employeesProjects" type="List"/>
<aura:attribute name="isModalOpen" type="boolean" default="false"/>
<lightning:notificationsLibrary aura:id="notifLib"/>
<lightning:navigation aura:id="navService"/>
<!-- beginning card do header-->
<lightning:card variant="Narrow" title="Projects Cards" iconName="standard:record" >
<aura:set attribute="actions">
<lightning:button label="New" onclick="{! c.openModel }"/>
</aura:set>
</lightning:card>
<!-- end card do header-->
<!-- beginning modal-->
<div class="slds-m-around_xx-large">
<!--Use aura:if tag to display/hide popup based on isModalOpen value-->
<aura:if isTrue="{!v.isModalOpen}">
<!-- Modal/Popup Box starts here-->
<section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<!-- Modal/Popup Box Header Starts here-->
<header class="slds-modal__header">
<h3 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">New Project</h3>
</header>
<!--Modal/Popup Box Body Starts here-->
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<lightning:recordForm
objectApiName="Project__c"
layoutType="Full"
mode="edit"
onsuccess="{!c.handleSuccess}"
oncancel="{!c.closeModel}"/>
</div>
<!--Modal/Popup Box Footer Starts here-->
</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</aura:if>
</div>
And here's my handleSuccess in the controller:
handleSuccess: function(component, event, helper) {
var params = event.getParams();
component.find("navService").navigate({
"type": "standard__recordPage",
"attributes": {
"recordId": params.response.id,
"objectApiName": "Project__c",
"actionName": "view"
}
});
component.set("v.isModalOpen", false);
}
Its not working. The record gets created but it prompts a popup message error instead of redirecting it to the new record.
[NoErrorObjectAvailable] Script error. a()@https://static.lightning.force.com/eu29/auraFW/javascript/5EkiQjrG-amda9Z1-HgsDQ/aura_prod.js:936:169 {anonymous}()@https://static.lightning.force.com/eu29/auraFW/javascript/5EkiQjrG-amda9Z1-HgsDQ/aura_prod.js:936:362 v.dispatchEvent()@https://static.lightning.force.com/eu29/auraFW/javascript/5EkiQjrG-amda9Z1-HgsDQ/aura_prod.js:4:25839 v.handleSuccess()@https://coee-management-dev-ed.lightning.force.com/components/lightning/recordForm.js:2:8296 o.createOrSaveRecord.then._pendingAction()@https://coee-management-dev-ed.lightning.force.com/components/interop/recordEditForm.js:2:7050
Could you please help me?