You need to sign in to do that
Don't have an account?
Nandu
Error message: Unable to read SObject
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" controller="lntg_DataTableClass" access="global" > <aura:attribute name="data" type="Object" default="{'sobjectType':'Account'}"/> <aura:attribute name="columns" type="List"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <lightning:card title="Account Editable Datatable"> <lightning:datatable aura:id="accountDataTable" keyField="id" data="{!v.data}" columns="{!v.columns}" onsave ="{!c.onSave}" hideCheckboxColumn="false"/> </lightning:card> </aura:component> ({ doInit : function(component, event, helper) { var tableHeder=[ {label: 'Name', fieldName: 'Name', editable:false, type: 'text'}, {label: 'Industry', fieldName: 'Industry', type: 'text'}, {label: 'Phone', fieldName: 'Phone', editable:true, type: 'Phone'}, {label: 'Rating', fieldName: 'Rating', editable:true, type: 'text'} ]; component.set("v.columns",tableHeder); helper.getdata(component,event,helper); }, onSave:function(component,event,helper){ helper.saveDataTable(component,event,helper); } }) ({ getdata : function(component,event,helper) { var action=component.get("c.getAccounts"); action.setCallback(this,function(response){ var state=response.getState(); if(state=="SUCCESS"){ component.set("v.data",response.getReturnValue()); } }); $A.enqueueAction(action); }, saveDataTable:function(component,event,helper){ var action=component.get("c.editRecordsupdated"); /*var editRec = component.find("accountDataTable").get("v.draftValues"); alert('editRec..'+JSON.stringify(editRec));*/ var draftValues = event.getParam('draftValues'); var editRecordsLenght=draftValues.length; alert('draftValues..'+draftValues); action.setParams({ 'editReds':draftValues }); action.setCallback(this,function(response){ var state=response.getState(); alert('state...'+state); if(state=="SUCCESS"){ if(response.getReturnValue() === true){ alert('Record updated'); helper.showToast({ "title": "Record Update", "type": "success", "message": editRecordsLenght+" Account Records Updated" }); helper.reloadDataTable(); } else{ //if update got failed helper.showToast({ "title": "Error!!", "type": "error", "message": "Error in update" }); } }else if (state === "INCOMPLETE") { // do something } else if (state === "ERROR") { var errors = response.getError(); if (errors) { if (errors[0] && errors[0].message) { console.log("Error message: " + errors[0].message); } } else { console.log("Unknown error"); } } }); $A.enqueueAction(action); }, /* * Show toast with provided params * */ showToast : function(params){ alert('showToast'); var toastEvent = $A.get("e.force:showToast"); if(toastEvent){ toastEvent.setParams(params); toastEvent.fire(); } else{ alert(params.message); } }, /* * reload data table * */ reloadDataTable : function(){ var refreshEvent = $A.get("e.force:refreshView"); if(refreshEvent){ refreshEvent.fire(); } } }) public class lntg_DataTableClass { @AuraEnabled public static List<Account> getAccounts(){ return[select id,name,industry,phone,rating from Account limit 5]; } @AuraEnabled public static Boolean editRecordsupdated(List<Account> editReds){ try{ System.debug('beforce editRecords..'+editReds); update editReds; System.debug('editRecords..'+editReds); return true; }catch(Exception e){ System.debug('e.'+e); return false; } } }
That profile having full permitions like view all and modifiy all but it's throwing error like Unable to read SObject
Thank you Raj
it's throwing same error....
Something like:
and then on the Apex Controller: