I am attempting to write multiple linked field values to a sigle new record. When I invoke the createRecordAsync method on the table, more than ten records (all with the same cell values) get written to the table. When I define the function as Async and use an await, no records end up getting created.
Code snippets below.
let operatorNamesField=tableOperators.getFieldByNameIfExists('Operator Names');
let operatorNamesRecord=useRecords(tableOperators, operatorNamesField);
let operatorNameOptions=operatorNamesRecord.map(operatorNamesRecord=>({
label: operatorNamesRecord.getCellValueAsString(operatorNamesField),
value: operatorNamesRecord.id
}));
//note: all of the select field options are formatted as above, but not shown for brevity
<Select
value={machineId}
options={machineNameOptions}
onChange={setMachineId}
/>
<Select
value={systemId}
options={systemNameOptions}
onChange={setSystemId}
/>
<Select
value={procedureId}
options={maintenanceProcedureOptions}
onChange={setProcedureId}
/>
<Select
value={operatorId}
options={operatorNameOptions}
onChange={setOperatorId}
/>
// The code then attempts to create a record using these values as part of an event triggered by a context dialog component
<React.Fragment>
<Button disabled={!checkBoxState || !operatorId ||!dateValue}
onClick={() => setIsDialogOpen(true)}>
Create a Maintenance Record
</Button>
{isDialogOpen && (
<ConfirmationDialog
isConfirmActionDangerous={true}
title="Are you sure?"
body="NOTE: A Record Cannot be Created Until All Fields Are Completed."
onConfirm={tableMaintenanceTickets.createRecordAsync({'Machine Number /
Station':[{id: machineId}],
'Task ID': [{id:procedureId}],
'Task Completed by': [{id: operatorId}]
}),
()=>setIsDialogOpen(false)
}
onCancel={() => setIsDialogOpen(false)}
/>
)}
</React.Fragment>