Scripting Block Help

I have a scripting block setup to create a series of 50 linked records when needed. These act as a checklist workflow and are linked to the original project in the other table.

My only issue is trying to pull in the Single Select field for City to fill in the 50 linked records. I need the city to pull from the selectedEvent and not the checklist template.

// pick tables from your base here
let checklist = base.getTable(‘Project Workflows’)
let templateView = base.getTable(‘Project Workflows’).getView(‘Expansion Workflow Template’);
let templateQuery = await templateView.selectRecordsAsync();
let templateRecords = templateQuery.records;
let noChecklist = base.getTable(‘Ongoing Projects’).getView(’**Expansion Projects ALL’);

// Select Event to Create Checklist
let selectedEvent = await input.recordAsync(‘Choose Event to Create Checklist’,noChecklist);

// create the tasks
let createRecords = templateRecords.map( c => ({fields: {

    'Task Subject': c.getCellValue('Task Subject'),
    'Project Link': [selectedEvent],
    'Tasks': c.getCellValue('Tasks'),
    'Task Assigned To': c.getCellValue('Task Assigned To'),
    'RE Stage': c.getCellValue('RE Stage'),
    'Project Phase': c.getCellValue('Project Phase'),
    'Project Type': c.getCellValue('Project Type'),
    'Task #': c.getCellValue('Task #'),
    'City': THIS IS WHERE I HIT MY ERROR. I NEED THIS FIELD TO PULL FROM THE SELECTED RECORD, NOT THE WORKFLOW SUMMARY VEW WHERE THE TASKS ARE PULLING FROM.

}})
);

if(selectedEvent)await checklist.createRecordsAsync(createRecords)
else output.markdown("# Uh-Oh You didn’t select an event!")

output.text(‘Done!’);

Try something like selectedEvent.getCellValue('name of city field')

Thanks for the suggestion, but it still gives me an error.

What is the field type of the source for the city? Its read type might be different from the write type of the target field.

Are you sure the city exists as an option for the target field? If both the origin and source fields are single select fields, the fields might have different choice ids, even if the have the same choice names.

You can also look at my script for copying the value one field to another and see how it handles different field types.

I see you stated the City field is a single select, so you’ll need something like this:

selectedEvent.getCellValue('name of city field').map(x => ({name: x.name}))