0

I have a 3 row actions for my datatable row. For some reason it is being block and console is saying it is a security error. I am not sure why error is occuring as I am just doing an alert.

Here is the error:

Refused to run the JavaScript URL because it violates the following Content Security Policy directive: "script-src 'self' 'nonce-032ebcb5-7130-bed3-6895-02101222c908' chrome-extension: 'unsafe-inline' 'unsafe-eval' https://sfdc.azureedge.net *.ap4.visual.force.com https://ssl.gstatic.com/accessibility/". Note that 'unsafe-inline' is ignored if either a hash or nonce value is present in the source list

Here is my code:

DataTable:

<lightning:datatable columns="{!v.columns}" data="{!v.data}" keyField="Id" hideCheckboxColumn="true" onRowAction="{!c.handleRowAction}" />

v.columns:

//Columns var actions = [ {label:'Edit',name:'edit'}, {label:'Delete',name:'delete'}, {label:'Close Task',name:'close_task'} ]; cmp.set('v.columns',[ {label:'Subject', fieldName:'linkName', type:'url', typeAttributes:{label:{fieldName:'Subject'}}, target:'_blank' }, //{label:'Name',fieldName:'WhoId',type:'text'}, //{label:'Task',fieldName:'IsTask',type:'boolean'}, {label:'Due Date',fieldName:'ActivityDate',type:'date'}, {label:'Status',fieldName:'Status',type:'picklist'}, {type:'action',typeAttributes:{rowActions:actions}} ]);

handleRowAction function:

handleRowAction : function(cmp,evt,hlpr) { var action = evt.getParam('action'); var row = evt.getParam('row'); switch(action.name) { case 'edit': alert('edit'); break; case 'delete' : console.log('delete '+row.Id); break; case 'close_task' : alert('close '+row.Id); break; }
}

I am not seeing what could be the issue.

  • Do you get the error when page loads or after doing the action? – Itai Shmida Mar 3 at 7:41
  • I am seeing the error after doing the action – Ferdy Reyes Mar 4 at 10:07
  • And if you put breakpoint there, what exactly do you get? On which line of code do you get the error? – Itai Shmida Mar 4 at 10:09
  • Thank you @ItaiShmida for looking into this. It seems that I should've use "onrowaction" instead of "onRowAction". That was firing the error. – Ferdy Reyes Mar 4 at 23:42
0

The error was that I should've type onrowaction instead of onRowAction as property o the lightning:datatable component. Answer is from my question in developer.salesforce.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.