I have an automation that is triggered when a user clicks a button in an interface. The automation is current set to simply create a new record in the underlying table, and fill in three fields:
user = should be the Name of the user who clicked the button. This is a "User" or "Collaborator" field in the underlying table. I have the user who clicks coming into the script using the input variable selector.
status = should be "Assigned" which is one of the possible values in the field, which is a single-select field.
string = "string is string" this is obviously a placeholder, but this is just a string.
Here's my code:
// Get the input variable
let inputConfig = input.config();
let userName = inputConfig.userName;
// Define the target table
let table = base.getTable('Table');
// Get the list of active collaborators in the base
let collaborators = base.activeCollaborators;
// Find the collaborator object that matches the userName
let assigneeCollaborator = collaborators.find(collaborator => collaborator.name === userName);
// Create a new record with the specified fields
await table.createRecordAsync({
'assignee': { assigneeCollaborator.name },
'phase': { name: 'Assigned' },
'string': 'string is string'
});
I had chatGPT o1-preview help with this, but continue to get errors related to the "assignee" field. After some iteration I got the "phase" field to work with the above, but have tried various version of the above, both simpler and more complex and cannot get the "assignee" field to accept the name of the person. If I output is with console.log, it looks just fine.
Any ideas what I can do here?