Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Jul 16, 2021 07:40 AM
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
Solved! Go to Solution.
Jul 20, 2021 04:03 PM
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"}
})
Jul 20, 2021 03:09 AM
Is there at all an option to write to a field in a different table after a record has been created?
Jul 20, 2021 07:29 AM
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.
Jul 20, 2021 07:29 AM
Yes, scripting app can update any field in any table as long as
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.
Jul 20, 2021 10:34 AM
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
Jul 20, 2021 04:03 PM
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"}
})
Jul 21, 2021 07:21 AM
Super sweet, that worked!
thanks much
Tom