diff --git a/force-app/main/default/lwc/odDatatable/odDatatable.js b/force-app/main/default/lwc/odDatatable/odDatatable.js
index 2a5094e..ed7e604 100644
--- a/force-app/main/default/lwc/odDatatable/odDatatable.js
+++ b/force-app/main/default/lwc/odDatatable/odDatatable.js
@@ -4,12 +4,17 @@ import { FlowNavigationNextEvent } from 'lightning/flowSupport';
import CSSStyles from '@salesforce/resourceUrl/OD_DatatableCSS';
import getFieldsForObject from '@salesforce/apex/OD_ConfigurationEditorController.getFieldsForObject';
import saveRecords from '@salesforce/apex/OD_ConfigurationEditorController.saveRecords';
-import { YES_NO, EMPTY_STRING, EVENTS, ROW_BUTTON_CONFIGURATION, INLINE_FLOW } from 'c/odDatatableConstants';
+import {
+ YES_NO,
+ EMPTY_STRING,
+ EVENTS,
+ ROW_BUTTON_CONFIGURATION,
+ INLINE_FLOW,
+ ROW_BUTTON_TYPE,
+} from 'c/odDatatableConstants';
import { reduceErrors, getFieldType, getPrecision, generateRandomNumber } from 'c/odDatatableUtils';
import OdDatatableFlow from 'c/odDatatableFlow';
-const ROW_BUTTON_TYPE = 'rowButtonType';
-
export default class ODDatatable extends LightningElement {
// internal use
@api uniqueTableName;
@@ -478,7 +483,7 @@ export default class ODDatatable extends LightningElement {
this._doUpdateOutputs(newRecord, EVENTS.ADD);
}
- async _doOpenFlow(record = undefined) {
+ _doAddEditWithFlow(record = undefined) {
const modalProps = {
size: 'small',
label: 'Edit or Add from a flow',
@@ -493,7 +498,30 @@ export default class ODDatatable extends LightningElement {
// this is an edit
modalProps.flowName = this.editFlowName;
modalProps.inputVariables = this.editFlowInputVariables ? JSON.parse(this.editFlowInputVariables) : [];
+ }
+
+ this._doOpenFlow(modalProps, record);
+ }
+ _doOpenFlowButton(fieldName, record) {
+ const modalProps = {
+ size: 'small',
+ label: 'Flow Button',
+ };
+
+ const column = this.columnsToShow.find((cl) => cl.fieldName === fieldName);
+
+ // this is an edit
+ modalProps.flowName = column.typeAttributes.config.flowName;
+ modalProps.inputVariables = column.typeAttributes.config.flowInputVariables
+ ? JSON.parse(column.typeAttributes.config.flowInputVariables)
+ : [];
+
+ this._doOpenFlow(modalProps, record);
+ }
+
+ async _doOpenFlow(modalProps, record = undefined) {
+ if (record) {
modalProps.inputVariables.unshift({
name: 'recordId',
type: 'String',
@@ -685,7 +713,7 @@ export default class ODDatatable extends LightningElement {
break;
case EVENTS.CHANGE:
if (this._editWithFlow) {
- this._doOpenFlow(record);
+ this._doAddEditWithFlow(record);
} else {
this._doChangeField(recordIndex, fieldName, value);
@@ -696,6 +724,9 @@ export default class ODDatatable extends LightningElement {
record = this.recordsToShow[recordIndex];
}
+ break;
+ case EVENTS.OPEN_FLOW:
+ this._doOpenFlowButton(fieldName, record);
break;
default:
break;
@@ -710,7 +741,7 @@ export default class ODDatatable extends LightningElement {
handleAdd() {
// add the record to the table with the defaults if inline, otherwise open the flow to add
if (this._addWithFlow) {
- this._doOpenFlow();
+ this._doAddEditWithFlow();
} else {
this._doAddRecord();
}
diff --git a/force-app/main/default/lwc/odDatatableConfigurationColumns/odDatatableConfigurationColumns.html b/force-app/main/default/lwc/odDatatableConfigurationColumns/odDatatableConfigurationColumns.html
index de6943f..8631e63 100644
--- a/force-app/main/default/lwc/odDatatableConfigurationColumns/odDatatableConfigurationColumns.html
+++ b/force-app/main/default/lwc/odDatatableConfigurationColumns/odDatatableConfigurationColumns.html
@@ -14,9 +14,13 @@
Select the columns you want to add to the table and configure each one
Editable? | Required? | Hidden? | -Default Value | +Default Value / Custom Column Configuration | Initial Width (px) | Order | @@ -49,13 +63,16 @@
---|---|---|---|---|---|---|
- |
|
-
- |
+
+
+
|
|
-
+
+
+
|
diff --git a/force-app/main/default/lwc/odDatatableConfigurationFlowInputVariables/odDatatableConfigurationFlowInputVariables.html b/force-app/main/default/lwc/odDatatableConfigurationFlowInputVariables/odDatatableConfigurationFlowInputVariables.html
index 22e28b8..b2c8f54 100644
--- a/force-app/main/default/lwc/odDatatableConfigurationFlowInputVariables/odDatatableConfigurationFlowInputVariables.html
+++ b/force-app/main/default/lwc/odDatatableConfigurationFlowInputVariables/odDatatableConfigurationFlowInputVariables.html
@@ -2,8 +2,8 @@
Configure Flow Input Variables
diff --git a/force-app/main/default/lwc/odDatatableConstants/odDatatableConstants.js b/force-app/main/default/lwc/odDatatableConstants/odDatatableConstants.js
index 2526fe9..aea3f73 100644
--- a/force-app/main/default/lwc/odDatatableConstants/odDatatableConstants.js
+++ b/force-app/main/default/lwc/odDatatableConstants/odDatatableConstants.js
@@ -22,6 +22,7 @@ export const FIELD_TYPES = {
TEXTAREA: 'textarea',
TOGGLE: 'toggle',
URL: 'url',
+ CUSTOM: 'custom',
};
export const TEXT_FIELDS = [
@@ -43,6 +44,12 @@ export const SERVER_SIDE_SEARCH = [FIELD_TYPES.LOOKUP];
export const FIELDS_STRING = [...TEXT_FIELDS, ...LOCAL_SIDE_SEARCH, ...SERVER_SIDE_SEARCH];
+export const CUSTOM_TYPES = {
+ SCREEN_FLOW: 'ScreenFlow',
+};
+
+export const BUTTON_TYPES = [CUSTOM_TYPES.SCREEN_FLOW];
+
export const FORMATTED_TYPE_TO_SHOW = {
address: {
label: 'Address',
@@ -119,6 +126,16 @@ export const FORMATTED_TYPE_TO_SHOW = {
label: 'URL',
maxLength: true,
},
+ custom: {
+ label: '',
+ options: [
+ {
+ value: CUSTOM_TYPES.SCREEN_FLOW,
+ label: 'Screen Flow',
+ flow: true,
+ },
+ ],
+ },
};
export const YES_NO = {
@@ -136,11 +153,17 @@ export const EMPTY_STRING = '--empty--';
export const EVENTS = {
ADD: 'add',
CHANGE: 'change',
+ OPEN_FLOW: 'openFlow',
DELETE: 'delete',
UNDELETE: 'undelete',
};
+export const ROW_BUTTON_TYPE = 'rowButtonType';
+
export const ROW_BUTTON_CONFIGURATION = {
+ OPEN_FLOW: {
+ action: EVENTS.OPEN_FLOW,
+ },
EDIT: {
_editAction: EVENTS.CHANGE,
},
diff --git a/force-app/main/default/lwc/odDatatableCustom/odDatatableCustom.js b/force-app/main/default/lwc/odDatatableCustom/odDatatableCustom.js
index 9fa59bf..1590cc4 100644
--- a/force-app/main/default/lwc/odDatatableCustom/odDatatableCustom.js
+++ b/force-app/main/default/lwc/odDatatableCustom/odDatatableCustom.js
@@ -23,7 +23,16 @@ export default class ODCustomDatatable extends LightningDatatable {
rowButtonType: {
template: rowButtonTemplate,
standardCellLayout: false,
- typeAttributes: ['recordId', 'iconName', 'tooltip', 'name', 'label', 'isDeleted', 'disableIfDeleted'],
+ typeAttributes: [
+ 'recordId',
+ 'iconName',
+ 'tooltip',
+ 'name',
+ 'label',
+ 'isDeleted',
+ 'disableIfDeleted',
+ 'fieldName',
+ ],
},
};
}
diff --git a/force-app/main/default/lwc/odDatatableCustom/rowButtonType.html b/force-app/main/default/lwc/odDatatableCustom/rowButtonType.html
index bf01c3c..1fb503e 100644
--- a/force-app/main/default/lwc/odDatatableCustom/rowButtonType.html
+++ b/force-app/main/default/lwc/odDatatableCustom/rowButtonType.html
@@ -7,6 +7,7 @@
tooltip={typeAttributes.tooltip}
name={typeAttributes.name}
label={typeAttributes.label}
+ field-name={typeAttributes.fieldName}
>
diff --git a/force-app/main/default/lwc/odDatatableRowButton/odDatatableRowButton.js b/force-app/main/default/lwc/odDatatableRowButton/odDatatableRowButton.js
index adb7bad..87d41cc 100644
--- a/force-app/main/default/lwc/odDatatableRowButton/odDatatableRowButton.js
+++ b/force-app/main/default/lwc/odDatatableRowButton/odDatatableRowButton.js
@@ -6,6 +6,7 @@ export default class OdDatatableRowButton extends LightningElement {
@api tooltip;
@api name;
@api label;
+ @api fieldName;
@api isDeleted;
@api disableIfDeleted;
@@ -26,6 +27,7 @@ export default class OdDatatableRowButton extends LightningElement {
cancelable: true,
detail: {
recordId: this.recordId,
+ fieldName: this.fieldName,
action: this.name,
},
});
|