Skip to main content
Solved

"Unnamed record" in automation script

  • February 10, 2023
  • 7 replies
  • 109 views

Forum|alt.badge.img+3

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!

Best answer by Grunty

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".

7 replies

kuovonne
Forum|alt.badge.img+29
  • Brainy
  • February 10, 2023

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?


Grunty
Forum|alt.badge.img+15
  • Inspiring
  • Answer
  • February 11, 2023

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".


Alexey_Gusev
Forum|alt.badge.img+25
  • Brainy
  • February 11, 2023

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'.


kuovonne
Forum|alt.badge.img+29
  • Brainy
  • February 13, 2023

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".



@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.


Grunty
Forum|alt.badge.img+15
  • Inspiring
  • February 13, 2023

@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.


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.


Alexey_Gusev
Forum|alt.badge.img+25
  • Brainy
  • February 14, 2023

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.


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 OKNow I understand what was wrong, thanks.


Forum|alt.badge.img+3
  • Author
  • New Participant
  • February 15, 2023

Thanks for everyone's input! Grunty, that fixed it 💥