On my Parent Lightning Element I have a data table where on Row Selection I want to open a custom Record Page in a Lightning Modal. I am struggling to extract the Id I am passing in the options array. I have placed the array in the Modal HTML to confirm it is outputting correctly. However when I use the following code to return the first element in the array I receive an Error (at bottom)
werRecordId = this.options[0];
Parent JS
handleRowSelection(event) {
this.werSelectedRowId = event.detail.selectedRows[0].Id;
MyModal.open({
options: [
this.werSelectedRowId,
]
}).then((result) => {
console.log(result);
});
}
Modal JS
import { api } from 'lwc';
import LightningModal from 'lightning/modal';
export default class MyModal extends LightningModal {
@api options;
werRecordId = this.options[0];
//werRecordId = 'a08030000014jjaAAA';
handleOptionClick(e) {
const { target } = e;
const { id } = target.dataset;
this.close(id);
}
}
Modal HTML
<template>
<lightning-modal-header label="My Modal Heading"></lightning-modal-header>
<lightning-modal-body>
{options}
<c-work-experience-record-page
record-id={werRecordId}
ondisablerowselect={hanldeDisableRowSelect}
onenablerowselect={hanldeEnableRowSelect}
></c-work-experience-record-page>
</lightning-modal-body>
<lightning-modal-footer>
<lightning-button label="OK" onclick={handleOkay}></lightning-button>
</lightning-modal-footer>
</template>
Error
[NoErrorObjectAvailable] Script error.
a()@https://static.lightning.force.com/cs196/auraFW/javascript/nv49ahbZfs85wzJXOZaywA/aura_prod.js:1000:112
{anonymous}()@https://static.lightning.force.com/cs196/auraFW/javascript/nv49ahbZfs85wzJXOZaywA/aura_prod.js:1000:305
dispatchEvent()@https://static.lightning.force.com/cs196/auraFW/javascript/nv49ahbZfs85wzJXOZaywA/aura_prod.js:13:46387
Na.dispatchEvent()@https://static.lightning.force.com/cs196/auraFW/javascript/nv49ahbZfs85wzJXOZaywA/aura_prod.js:13:13839
Na.fireSelectedRowsChange()@https://falcon-pe--dxtest.sandbox.lightning.force.com/components/lightning/datatable.js:1:95086
Na.zn()@https://falcon-pe--dxtest.sandbox.lightning.force.com/components/lightning/datatable.js:1:49259
Na.handleSelectionCellClick()@https://falcon-pe--dxtest.sandbox.lightning.force.com/components/lightning/datatable.js:1:93785