Feb 10, 2023 06:51 AM
Hey there - script writing newbie here. Anyone know why this is returning "Unnmed record" in my summary? The primary field definitely is not blank. It's a single line text field, some of which are a bit longer, with 20 words.
Appreciate the help!
Solved! Go to Solution.
Feb 10, 2023 06:30 PM
Hey Matthew,
The definition of the query for 'To Do List' is missing the name field:
let linkedQuery = await linkedTable.selectRecordsAsync({fields: ['Primary field name here!', 'Status Calc']});
In your code, when you reference 'incomplete.name' in the summary, the interpreter assumes the existence of a name field, but finds no values retrieved for it, hence labels them "Unnamed record".
Feb 10, 2023 08:50 AM
What displays if you do a console.log(incompleteRecords)? Do the names show up there? Can you match the record IDs of the records with the records in the grid view to ensure that you actually have the correct records?
Feb 10, 2023 06:30 PM
Hey Matthew,
The definition of the query for 'To Do List' is missing the name field:
let linkedQuery = await linkedTable.selectRecordsAsync({fields: ['Primary field name here!', 'Status Calc']});
In your code, when you reference 'incomplete.name' in the summary, the interpreter assumes the existence of a name field, but finds no values retrieved for it, hence labels them "Unnamed record".
Feb 11, 2023 05:05 AM
Hi,
Would like to suggest - you can use selectRecordAsync(id) to retrieve a single record (lines 5,6).
You can also put a part of your scripting job to the native automation by retrieving array of IDs (from 'To Do list') into another input varialble. Use 'Edit token', make a new list of... (and you can also retrieve list of Names)
(just for example)
I think, it may help you to debug the issue with 'Unnamed'
Also, just for info - you can get your linkedRecords directly in line 7, without line 8, using not only 'fields:', but another option - 'recordIDs'.
Feb 13, 2023 12:37 PM
@Grunty wrote:In your code, when you reference 'incomplete.name' in the summary, the interpreter assumes the existence of a name field, but finds no values retrieved for it, hence labels them "Unnamed record".
The ".name" property of the record exists, even if the primary field has not been included in the query results. It is also slightly different from the primary field value. The name property of a record is always a text string, but the primary field value could be a number or a date.
Feb 13, 2023 03:49 PM - edited Feb 13, 2023 03:50 PM
Yes, the ".name" property of the record always exists, as it’s a part of the object structure. But it being fed actual values depends on whether the primary field is declared in the query enumeration or not.
I recall a stormy night I was console.logging records using .name and it wouldn’t appear on the log. It took me a while to realise that I had missed declaring the primary field on the query. Once I did, the values of record.name showed up on the log.
I see in Matthew’s screenshot that seems to be the case.
Feb 14, 2023 04:03 AM
I remember I encounter some bug using .name, results were different from expected. I had no time to investigate deeper, when I changed it to .getCellValue('Primary_field_name') and added it to {fields:}, it worked OK. Now I understand what was wrong, thanks.
Feb 15, 2023 01:50 PM
Thanks for everyone's input! Grunty, that fixed it 💥