Skip to content

Commit e67e68d

Browse files
authored
chore: allow lookup for blank cells in Excel actions (#1132)
## Problem Users are unable to search for blank values in their Excel columns using the “Find table row” or “Find table rows” actions. This is a key difference between Tiles and M365 Excel, which often requires a workaround: creating a column specifically for lookup purposes and then updating that column’s value once the workflow is completed. ## Solution Change the `required` property of the lookup value field from `true` to `false` ## Tests - [ ] Existing Excel steps that were previously set up still work - [ ] 'Check step' is allowed when lookup value is empty - [ ] Find table row - [ ] Find table rows - [ ] Update existing Excel step's lookup value to empty, should still be able to fetch row(s) - [ ] Find table row - [ ] Find table rows - [ ] New Excel steps can set lookup value to empty, and can still fetch row(s) - [ ] Find table row - [ ] Find table rows ## Before & After Screenshots https://github.com/user-attachments/assets/00a42934-4a12-4978-bb40-a48fb04108a1
1 parent 1ab14fa commit e67e68d

File tree

5 files changed

+59
-6
lines changed

5 files changed

+59
-6
lines changed

packages/backend/src/apps/m365-excel/__tests__/actions/get-table-rows.itest.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ describe('getTableRowsAction', () => {
8383
['non-matching', 'data1'],
8484
['test-value', 'data2'],
8585
['test-value', 'data3'],
86+
['', 'data4'],
87+
['row5', ''],
88+
['', 'data6'],
8689
],
8790
headerSheetRowIndex: 0,
8891
})
@@ -202,6 +205,56 @@ describe('getTableRowsAction', () => {
202205
expect(rowData[1].data[getHexEncodedColumnName('Column2')]).toBe('data3')
203206
})
204207

208+
it('should return matching rows when lookup value is empty', async () => {
209+
$.step.parameters.lookupValue = ''
210+
await getTableRowsAction.run($)
211+
212+
expect($.setActionItem).toHaveBeenCalledWith({
213+
raw: expect.objectContaining({
214+
rowsFound: 2,
215+
data: {
216+
columns: expect.arrayContaining([
217+
expect.objectContaining({
218+
id: getHexEncodedColumnName('Column1'),
219+
name: 'Column1',
220+
value: `data.rows.*.data.${getHexEncodedColumnName('Column1')}`,
221+
}),
222+
expect.objectContaining({
223+
id: getHexEncodedColumnName('Column2'),
224+
name: 'Column2',
225+
value: `data.rows.*.data.${getHexEncodedColumnName('Column2')}`,
226+
}),
227+
]),
228+
rows: expect.arrayContaining([
229+
expect.objectContaining({
230+
data: {
231+
[getHexEncodedColumnName('Column1')]: '',
232+
[getHexEncodedColumnName('Column2')]: 'data4',
233+
},
234+
}),
235+
expect.objectContaining({
236+
data: {
237+
[getHexEncodedColumnName('Column1')]: '',
238+
[getHexEncodedColumnName('Column2')]: 'data6',
239+
},
240+
}),
241+
]),
242+
inputSource: FOR_EACH_INPUT_SOURCE.M365_EXCEL,
243+
},
244+
}),
245+
})
246+
247+
// Verify the rowData contains the expected rows
248+
const call = ($.setActionItem as ReturnType<typeof vi.fn>).mock.calls[0][0]
249+
const rowData = call.raw.data.rows
250+
251+
expect(rowData).toHaveLength(2)
252+
expect(rowData[0].data[getHexEncodedColumnName('Column1')]).toBe('')
253+
expect(rowData[0].data[getHexEncodedColumnName('Column2')]).toBe('data4')
254+
expect(rowData[1].data[getHexEncodedColumnName('Column1')]).toBe('')
255+
expect(rowData[1].data[getHexEncodedColumnName('Column2')]).toBe('data6')
256+
})
257+
205258
it('should handle invalid parameters', async () => {
206259
$.step.parameters.fileId = ''
207260
await expect(getTableRowsAction.run($)).rejects.toThrow(StepError)

packages/backend/src/apps/m365-excel/actions/get-table-row/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ const action: IRawAction = {
104104
// weird (e.g. currency cells have a trailing space), and will lead to too
105105
// much user confusion.
106106
description:
107-
'Case sensitive and should not include units. E.g. $5.20 → 5.2',
107+
'Case sensitive and should not include units (e.g., $5.20 → 5.2). Leave blank to search for empty cells.',
108108
type: 'string' as const,
109-
required: true,
109+
required: false,
110110
variables: true,
111111
hiddenIf: {
112112
fieldKey: 'tableId',

packages/backend/src/apps/m365-excel/actions/get-table-row/schemas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const parametersSchema = z.object({
1717
}),
1818
// * We don't trim as we want to match _exactly_ on the user's input.
1919
// * We allow empty strings to support optional form fields.
20-
lookupValue: z.string(),
20+
lookupValue: z.string().default(''),
2121
})
2222

2323
export const dataOutSchema = z.discriminatedUnion('foundRow', [

packages/backend/src/apps/m365-excel/actions/get-table-rows/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ const action: IRawAction = {
103103
// weird (e.g. currency cells have a trailing space), and will lead to too
104104
// much user confusion.
105105
description:
106-
'Case sensitive and should not include units. E.g. $5.20 → 5.2',
106+
'Case sensitive and should not include units (e.g., $5.20 → 5.2). Leave blank to search for empty cells.',
107107
type: 'string' as const,
108-
required: true,
108+
required: false,
109109
variables: true,
110110
},
111111
],

packages/backend/src/apps/m365-excel/actions/get-table-rows/schemas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const parametersSchema = z.object({
1717
}),
1818
// * We don't trim as we want to match _exactly_ on the user's input.
1919
// * We allow empty strings to support optional form fields.
20-
lookupValue: z.string(),
20+
lookupValue: z.string().default(''),
2121
})
2222

2323
export const dataOutSchema = z.object({

0 commit comments

Comments
 (0)