You need to sign in to do that
Don't have an account?
Mạnh Nguyễn
Error : Cannot read property 'setParams' of undefined
i have a quest :
- create a list view contact
- list have edit + view button
this is my code :
listview.cmp
listviewController.js
contactController.apxc
i used this doc :
https://developer.salesforce.com/docs/component-library/bundle/force:editRecord/documentation
Error :
This page has an error. You might just need to refresh it. Action failed: c:listView$controller$handleRowAction [Cannot read property 'setParams' of undefined] Failing descriptor: {c:listView$controller$handleRowAction}
please someone have me, thanks.
- create a list view contact
- list have edit + view button
this is my code :
listview.cmp
<aura:component controller="ContactController" implements="force:appHostable, flexipage:availableForAllPageTypes, force:hasRecordId"> <aura:attribute type="Contact[]" name="contList"/> <aura:attribute name="mycolumns" type="List"/> <aura:handler name="init" value="{!this}" action="{!c.fetchCt}"/> <lightning:datatable data="{! v.contList }" columns="{! v.mycolumns }" keyField="id" hideCheckboxColumn="true" onrowaction="{!c.handleRowAction}" />" </aura:component>
listviewController.js
({ fetchCt : function(component, event, helper) { var actions = [ {label:'Edit',name:'edit'}, {label:'View',name:'view'} ]; component.set('v.mycolumns', [ {label: 'ContactName', fieldName: 'Name', type: 'text'}, {label: 'Email', fieldName: 'Email', type: 'text'}, {label: 'Phone', fieldName: 'Phone', type: 'Phone'}, {label: 'Title', fieldName: 'Title', type: 'Text'}, {label:'Status',fieldName:'Status',type:'picklist'}, {type:'action',typeAttributes:{rowActions:actions}} ]); var action = component.get("c.fetchContacts"); action.setCallback(this, function(response){ var state = response.getState(); if (state === "SUCCESS") { component.set("v.contList", response.getReturnValue()); } }); $A.enqueueAction(action); }, handleRowAction: function ( cmp, event, helper ) { var action = event.getParam( 'action' ); var row = event.getParam( 'row' ); var recId = row.Id; console.log('RecordId',recId); switch ( action.name ) { case 'edit': var editRecordEvent = $A.get("e.force:editRecord"); editRecordEvent.setParams({ "recordId": recId }); editRecordEvent.fire(); break; case 'view': var viewRecordEvent = $A.get("e.force:navigateToURL"); viewRecordEvent.setParams({ "url": "/" + recId }); viewRecordEvent.fire(); break; } } })
contactController.apxc
public class ContactController { @AuraEnabled public static List <Contact> fetchContacts() { //Qyery 10 accounts List<Contact> contList = [Select Id, Name, Email, Title, Phone From Contact]; //return list of accounts return contList; } }
i used this doc :
https://developer.salesforce.com/docs/component-library/bundle/force:editRecord/documentation
Error :
This page has an error. You might just need to refresh it. Action failed: c:listView$controller$handleRowAction [Cannot read property 'setParams' of undefined] Failing descriptor: {c:listView$controller$handleRowAction}
please someone have me, thanks.
I think you previewing the component through <aura:application extends="force:slds">.
then e.force:editRecord and e.force:navigateToURL will not work in Lightning Standalone App.
You can drag this same component in lighnting Home page or Record Pages via app builder then it will work.
Thanks,
Maharajan.C
All Answers
I think you previewing the component through <aura:application extends="force:slds">.
then e.force:editRecord and e.force:navigateToURL will not work in Lightning Standalone App.
You can drag this same component in lighnting Home page or Record Pages via app builder then it will work.
Thanks,
Maharajan.C
And
just run in a org,
sr for my question
Are asking where u have to run this component?
e.force:editRecord and e.force:navigateToURL will not work in Lightning Standalone App.
thanks for support, Maharajan C
I was also facing same issue, Now its working.