Help

Re: Updating a field in linked table in just created record and open the record

Solved
Jump to Solution
1891 2
cancel
Showing results for 
Search instead for 
Did you mean: 
capt
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi

This relates to this Topic

This is the code I have:

let repoT = base.getTable('Repo');
let sourceT = base.getTable('Source');

let record = await input.recordAsync('Pick a record', sourceT);
// let name = record.getCellValue('Part 1') + '-' + record.getCellValue('Part 2');

if (!record.getCellValue('Repo')) {
    let name = record.getCellValue('Data');
    // create the record in the repo table
    let newRepoRecord = await repoT.createRecordAsync({
            'Name': name
    })
        // set variable for today's date
    let now = new Date().toLocaleDateString("en-GB");
    //note that newRepoRecord is the record ID of the created record
    // see this by logging the result:

    console.log(newRepoRecord);

    // now take the newly created record ID
    // and set the linked field from this
    let updatedRecord = await sourceT.updateRecordAsync(record, {
        'Repo': [{id: newRepoRecord}],
        'Part Created': "Part Entered " + now
    })
} else {
    console.log("Repo is already linked for this record");
}

I want to be able to update a field in the newly created record in the repoT table.
The field is called Type and the Value I like to write is Test. the field is a Single Select field.

After I created the record and updated the field I would like the user to be prompted with the expanded field view of that record.

Is there a way of achieving this?

many thanks
Tom

1 Solution

Accepted Solutions

This modification to the part of the script that creates the record should do the trick:

let newRepoRecord = await repoT.createRecordAsync({
            'Name': name,
            'Type': {name: "Test"}
    })

See Solution in Thread

6 Replies 6
capt
5 - Automation Enthusiast
5 - Automation Enthusiast

Is there at all an option to write to a field in a different table after a record has been created?

Unfortunately not. Record expansion is only possible interactively by pressing the space bar when in a record field.

This is definitely possible within the script as long as you know the ID of the record that you wish to update.

Yes, scripting app can update any field in any table as long as

  • the user running the script has the necessary permissions, and
  • the script can identify the table and record to update.

Scripting app cannot open the expanded view of a record. It can show a link to the record that will open the expanded view in a new browser window when clicked.

capt
5 - Automation Enthusiast
5 - Automation Enthusiast

hi @Justin_Barrett @kuovonne

thanks both so much for your response. Ok the expanded record I strike from the wish list.

Assuming the code above is my code and the record that I have just created with that code is the one the I want to change the value in field {Type} to “Test” how would I need to adapt that code to achieve this?

Thanks so much
Tom

This modification to the part of the script that creates the record should do the trick:

let newRepoRecord = await repoT.createRecordAsync({
            'Name': name,
            'Type': {name: "Test"}
    })

Super sweet, that worked!

thanks much
Tom