I'm looking on how to pass the selected rows in a Flexcard data table to a parent omniscript. In this piece of documentation it only says that everytime a row is selected it triggers the "selectrow" event, but I'm not being able to get the event details in a parent omniscript not even in the parent flexcard. I'm not quite sure on how to handle the event listener (not to mention that since I can't see the event, I'm clueless on how to save the array sent by it).
Datatable Flexcard #Omnistudio
Hi @Walter Fernandez. You can add the FlexCard to an LWC and handle the event programmatically as per https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.events_handling. See 'Attach an Event Listener Programmatically.' The code below defines an LWC that updates the OmniScript JSON with the selected rows. Also useful: https://help.salesforce.com/s/articleView?id=sf.os_datatable_lightning_web_component_readme.htm&type=5
Update: video explanation of selectrow event handling here: https://www.youtube.com/watch?v=WnHIXSzcdKM
Update 2: see this resource for more details and sample code on this topic https://quip.com/ftaxAqKJknkj
<template>
<!-- Embedded Flexcard -->
<c-cf-test-data-table-selectable></c-cf-test-data-table-selectable>
</template>
import { LightningElement, api, track } from 'lwc';
import { OmniscriptBaseMixin } from 'omnistudio/omniscriptBaseMixin';
export default class DatatableSelectable extends OmniscriptBaseMixin(LightningElement) {
selectedRows=[];
connectedCallback(){
this.template.addEventListener('selectrow', evt => {
console.log('selectrow event', JSON.stringify(evt.detail.result));
// if event's selectrow is true, add it to selectedRows; if false, it's been unchecked >> remove it
if (evt.detail.result.selectrow) {
this.selectedRows.push(evt.detail.result);
} else {
this.selectedRows.forEach(function(item, index, object) {
if (item.uniqueKey === evt.detail.result.uniqueKey) {
object.splice(index, 1);
}
})
}
this.omniApplyCallResp({"selectedRows": this.selectedRows });
});
}
}