My_Test_Repo/force-app/main/default/lwc/customLookup/customLookup.js

31 lines
1.1 KiB
JavaScript

import { LightningElement,wire } from 'lwc';
import findAccounts from '@salesforce/apex/AccountController.findAccounts';
export default class customLookup extends LightningElement {
value = '';
resultObj = []; // Declare an object to store the result
handleOnChange(event){
this.value = event.target.value;
console.log(this.value);
findAccounts({searchKey: this.value})
.then(result => {
this.resultObj = result; // Store the result in the object
console.log("Printing reslt ",this.resultObj); // Log the object
})
.catch(error => {
console.error(error);
});
}
handleMouseOver(event) {
const recordId = event.currentTarget.dataset.id;
const record = this.resultObj.find(rec => rec.Id === recordId);
record.showCard = true;
}
handleMouseOut(event) {
const recordId = event.currentTarget.dataset.id;
const record = this.resultObj.find(rec => rec.Id === recordId);
record.showCard = false;
}
}