Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,44 @@ export default class Datatable extends LightningElement {
dateFieldArray = [];
datetimeFieldArray = [];
@api picklistFieldArray = [];
@api picklistReplaceValues = false;
apex_picklistFieldMap = [];
@api picklistReplaceValues = false;
@api
get apex_picklistFieldMap() {
return this._apex_picklistFieldMap || {};
}
set apex_picklistFieldMap(value) {
try {
const isValidString = (typeof value === 'string' && value?.trim()?.length > 0);
this._apex_picklistFieldMap = (isValidString) ? this.convertPicklistFormat(JSON.parse(value)) : [];
} catch (e) {
console.log('Error parsing apex_picklistFieldMap JSON:', e);
this._apex_picklistFieldMap = [];
}
}
_apex_picklistFieldMap = {};

convertPicklistFormat(picklistMap) {
// Convert from user-friendly format: {"fieldName": [{"label":"...", "value":"..."}]}
// To internal format: {"fieldName": {"label": "value"}}
const converted = {};
Object.keys(picklistMap).forEach(fieldName => {
const fieldValues = picklistMap[fieldName];
if (Array.isArray(fieldValues)) {
// Convert array format to object format
converted[fieldName] = {};
fieldValues?.forEach(item => {
if (item?.label && item?.hasOwnProperty('value')) {
converted[fieldName][item?.label] = item?.value;
}
});
} else {
// Already in internal format, use as-is
converted[fieldName] = fieldValues;
}
});
return converted;
}

@api picklistMap = [];
@api edits = [];
@api isEditAttribSet = false;
Expand Down Expand Up @@ -1354,11 +1390,13 @@ export default class Datatable extends LightningElement {
if (this.picklistReplaceValues) {
let noMatch = false;
this.picklistFieldArray.forEach(picklist => {
Object.keys(this.apex_picklistFieldMap[picklist]).forEach(map => {
if (map != this.apex_picklistFieldMap[picklist][map]) {
noMatch = true;
}
});
if (this.picklistFieldMap[picklist]) {
Object.keys(this.picklistFieldMap[picklist]).forEach(map => {
if (map != this.picklistFieldMap[picklist][map]) {
noMatch = true;
}
});
}
});
this.picklistReplaceValues = noMatch;
}
Expand Down Expand Up @@ -1518,10 +1556,10 @@ export default class Datatable extends LightningElement {
// Handle replacement of Picklist API Names with Labels
if (this.picklistReplaceValues) {
picklistFields.forEach(picklist => {
if (record[picklist]) {
if (record[picklist] && this.picklistFieldMap[picklist]) {
let picklistLabels = [];
record[picklist].split(';').forEach(picklistValue => {
picklistLabels.push(this.apex_picklistFieldMap[picklist][picklistValue]);
record[picklist].split(';').forEach(picklistValue => {
picklistLabels.push(this.picklistFieldMap[picklist][picklistValue]);
});
record[picklist] = picklistLabels.join(';');
}
Expand Down Expand Up @@ -1713,6 +1751,16 @@ export default class Datatable extends LightningElement {
this.typeAttrib = [];
this.typeAttrib.type = type;
}

// Convert 'picklist' to 'combobox' if picklist values are available (from apex or wire service)
if (this.typeAttrib.type === 'picklist') {
const hasApexPicklistValues = this.apex_picklistFieldMap && this.apex_picklistFieldMap[fieldName];
const hasWirePicklistValues = this._picklistData && this._picklistData.picklistFieldValues && this._picklistData.picklistFieldValues[fieldName];
if (hasApexPicklistValues || hasWirePicklistValues) {
this.typeAttrib.type = 'combobox';
type = 'combobox';
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<property name="serializedRecordData" label="_ (User Defined) Display Serialized Record?" type="String" default="false" role="inputOnly" description="String variable containing the records. Serialized record data."/>
<property name="isSerializedRecordData" type="Boolean" role="inputOnly"/>
<property name="cb_isSerializedRecordData" type="String" role="inputOnly"/>
<property name="apex_picklistFieldMap" label="_ (User Defined) Picklist Field Map" type="String" role="inputOnly" description="JSON string containing picklist values for user-defined objects."/>
<!-- =========== Outputs =========== -->
<property name="outputSelectedRowsString" label="Output Selected Rows (User Defined)" type="String" role="outputOnly" description="Object Collection string variable to contain only the records that were selected in the datatable.
-- NOTE: These records may not contain all of the edited values."/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,22 @@ <h2 class="slds-modal__title slds-hyphenate">Configure Columns</h2>
automatic-output-variables={automaticOutputVariables}>
</c-fsc_flow-combobox>

<!-- Picklist Field Map (Apex-Defined) -->
<c-fsc_flow-combobox
if:false={isSObjectInput}
name="select_apex_picklistFieldMap"
label={inputValues.apex_picklistFieldMap.label}
value={inputValues.apex_picklistFieldMap.value}
value-type={inputValues.apex_picklistFieldMap.valueDataType}
field-level-help={inputValues.apex_picklistFieldMap.helpText}
builder-context-filter-collection-boolean={inputValues.apex_picklistFieldMap.isCollection}
builder-context={_builderContext}
allow-hard-code-reference=true
placeholder-text="Manual entry allowed"
onvaluechanged={handleFlowComboboxValueChange}
automatic-output-variables={automaticOutputVariables}>
</c-fsc_flow-combobox>

<!-- Special Column CellAttribs -->
<c-fsc_flow-combobox
name="select_columnCellAttribs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,10 @@ export default class ers_datatableCPE extends LightningElement {
helpText: 'Record Collection variable containing the records to show as pre-selected in the datatable.'},
tableDataString: {value: null, valueDataType: null, isCollection: false, label: 'Datatable Record String',
helpText: 'Object Collection string variable containing the records to display in the datatable.'},
preSelectedRowsString: {value: null, valueDataType: null, isCollection: false, label: 'Pre-Selected Rows String',
preSelectedRowsString: {value: null, valueDataType: null, isCollection: false, label: 'Pre-Selected Rows String',
helpText: 'Object Collection string variable containing the records to show as pre-selected in the datatable.'},
apex_picklistFieldMap: {value: null, valueDataType: null, isCollection: false, label: 'Column Picklist Values (Apex-Defined Only)',
helpText: 'JSON string containing picklist values for user-defined objects. Format: {"fieldName":[{"label":"Label1","value":"Value1"}]}'},
columnFields: {value: null, valueDataType: null, isCollection: false, label: 'Column Fields',
helpText: "REQUIRED: Comma separated list of field API Names to display in the datatable.",
isError: false, errorMessage: null},
Expand Down Expand Up @@ -802,6 +804,7 @@ export default class ers_datatableCPE extends LightningElement {
{name: 'columnFlexes'},
{name: 'columnWraps'},
{name: 'columnCellAttribs'},
{name: 'apex_picklistFieldMap'},
{name: 'columnTypeAttribs'},
{name: 'columnOtherAttribs'},
{name: 'recordTypeId'},
Expand Down