0

I want to show account record on checking a checkbox and delete the selected record and refresh list but I am getting errors. duplicate value found: duplicates value on record with id: Cannot find Lightning Component Bundle DeleteSelectedAcct. Cannot find Lightning Component Bundle DeleteSelectedAcct.

help me to resolve it plz

deleteSelectedAcct.html

<template>
<lightning-card>
    <lightning-input label="show:hide" type="checkbox" checked={showFields} onchange={togglerFields}></lightning-input>
<lightning-button slot = "actions" label="delete account" onclick={deleteRecord}></lightning-button>
<template if:true={showFields}>
    <template if:true = {accList.data}>
        <lightning-datatable 
                data={accList} 
                columns={columns} 
                key-field="Id"
                max-row-selection="2" 
                onrowselection={handelSelection} > 
        </lightning-datatable>


    </template>
    
</template>


</lightning-card>

deleteSelectedAcct.js

  import { LightningElement,track,wire } from 'lwc';
  import delAccount from '@salesforce/apex/DeleteSelectedAccount.delAccount';
  import {deleteRecord} from 'lightning/uiRecordApi';
   import {RefreshApex} from '@salesforce/apex';


   export default class DeleteSelectedAcct extends LightningElement {


   columns =[
   {
       label :'Name',
        fieldName : 'Name',
         Type : 'text'}
   ]
   showFields=true;
   accList;

   @track selectedRecord;
   @track accountList = [];
   @track error;
   @track wiredAccountList = [];

   toggleFields() {
   this.showFields = !this.showFields;
    }



   @wire(delAccount) accList(result) {
   this.wiredAccountList = result;

    if (result.data) {
     this.accountList = result.data;
     this.error = undefined;
  }     else if (result.error) {
  this.error = result.error;
  this.accountList = [];
     }
  }
 handelSelection(event) {
   if (event.detail.selectedRows.length > 0) {
    this.selectedRecord = event.detail.selectedRows[0].Id;
    }
   }
  deleteRecord() {
  deleteRecord(this.selectedRecord)
  .then(() => {
    refreshApex(this.wiredAccountList);
  })
  .catch(error => {
     }   )
  }

}

apex class

public with sharing class DeleteSelectedAccount {

@AuraEnabled(Cacheable=true)
public static List<Account> delAccount(){
    return[select name from Account];
    
}

}
1
  • I think this code is fine, but wherever you're trying to call this from is using c:DeleteSelectedAcct instead of c:deleteSelectedAccount. Or, you might have an Aura Component by the same name.
    – sfdcfox
    Apr 26 at 12:00

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.