Help

Re: Error: Field "fldxxx" cannot accept the provided value with automation scripting

Solved
Jump to Solution
286 1
cancel
Showing results for 
Search instead for 
Did you mean: 
jonno
4 - Data Explorer
4 - Data Explorer

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?

1 Solution

Accepted Solutions
TheTimeSavingCo
18 - Pluto
18 - Pluto

Try changing your input variable to be the user ID instead:

Screenshot 2024-11-06 at 9.56.45 AM.png

And then use this:

// Get the input variable
let {userId} = input.config()
// Define the target table
let table = base.getTable('Table');

// Create a new record with the specified fields
await table.createRecordAsync({
    'Assignee': {id: userId},
});


If your User field allows for multiple users, you'll need to use the following for the record creation bit:

// Create a new record with the specified fields
await table.createRecordAsync({
    'Assignee': [{id: userId}],
});

 

See Solution in Thread

2 Replies 2
TheTimeSavingCo
18 - Pluto
18 - Pluto

Try changing your input variable to be the user ID instead:

Screenshot 2024-11-06 at 9.56.45 AM.png

And then use this:

// Get the input variable
let {userId} = input.config()
// Define the target table
let table = base.getTable('Table');

// Create a new record with the specified fields
await table.createRecordAsync({
    'Assignee': {id: userId},
});


If your User field allows for multiple users, you'll need to use the following for the record creation bit:

// Create a new record with the specified fields
await table.createRecordAsync({
    'Assignee': [{id: userId}],
});

 

That worked great!

I think one problem was just that I did not understand using ID as input and even as the value in the field would work to actually put the name when looking at the table, so I just avoided it. Thank you for making me try it!