0

Let's say I have a LWC with the following JS controller

export default class Approvals extends LightningElement {
    @track pendingApprovalHistories =[
        { Name : "Han Solo", CreatedDate : "test123" }
    ];
    actions = [
        { label: 'Make Decision', name: 'make_decision' },
    ];
   columns = [
        { label: 'Name', fieldName: 'name',  sortable: true },
        { label: 'Opportunity Owner', fieldName: 'opportunityOwnerName' },
        { label: 'Relationship Name', fieldName: 'accountName' },
        { label: 'Primary Approver', fieldName: 'ownerName' },
        { label: 'Created Date', fieldName: 'createdDate' },
        {
            type: 'action',
            typeAttributes: { rowActions: this.actions },
        },
    ];
    handleRowAction(event) {
        console.log(JSON.stringify("Hello!"));
        const actionName = event.detail.action.name;
        const row = event.detail.row;
        this.makeDecision(row);
    }
    makeDecision(row) {
        console.log(JSON.stringify("Hello2!")); 
    }
}

and the following markup

<template>
<lightning-datatable key-field="id" hide-checkbox-column data={pendingApprovalHistories} columns={columns} onrowaction={handleRowAction}>
</lightning-datatable>
</template

It renders appropriately, like this: Date Table drop down

However, when I click "Make Decision" I get the following message in the console:

"Refused to run the JavaScript URL because it violates the following Content Security Policy directive: "script-src 'self' 'nonce-b967bb2d-882a-46e4-b1d4-5fd89120ff7c' chrome-extension: 'unsafe-inline' 'unsafe-eval' https://sfdc.azureedge.net *.cs50.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."

Does anyone know what causes this error? It is preventing me from rerendering the page when I implement more logic in the makeDecision function.

  • Not an official answer, but from my anecdotal evidence from using the Aura flavor (it also does that) and am currently using the LWC flavor - it doesn't seem to have any negative impact to the rest of the UI or event interactions. 1.5 years using it in Aura, LWC since GA. I have at least 30+ datatables floating around using the base components. – tsalb Apr 25 at 3:05
  • You will receive this but it won't stop your work. I am facing too but all the things are running after that. – Vishnu Kumar Apr 25 at 18:01

Your Answer

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

Browse other questions tagged or ask your own question.