
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2022 03:08 PM
Hello,
I believe this is simple, but I don’t understand what syntax is needed. I’m trying to read the results of a single-select field as a string. I’m doing a running total calculation, but resetting it whenever a certain reading is found. The running total part was working, but I can’t figure out how to get the single select output as a string.
When I run this, I get:
typeof respGroup.records[0] returns “Object”
output.text(typeof respGroup.records[0].getCellValueAsString) returns “Function”
let table = base.getTable(‘Prints’);
let view = table.getView(‘MTBF layout’);
let respGroup = await view.selectRecordsAsync({fields: [‘NDD - Responsible Group’]}); //NDD - Responsible Group must be manually filled out!
let elapsedTime = await view.selectRecordsAsync({fields: [‘NDD - Elapsed print time’]}); //NDD - Elapsed print time is a calculated field
let groupRecords = respGroup.records;
//trying to understand how to get the group records into a string format
output.text(typeof respGroup.records[0])
output.text(“and the record is”)
output.text(typeof respGroup.records[0].getCellValueAsString)
Solved! Go to Solution.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2022 03:49 PM
Like I showed in my example, you have to actually tell the script which field. .getCellValueAsString("Name or ID of Field")

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2022 03:42 PM
Get any cell value as a string with the aptly named function record.getCellValueAsString("Name or ID of Field")

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2022 03:46 PM
Thank you. I must be referencing the records incorrectly. Could you help me with that syntax? I ran a test and got this output for the first index:
output.text(typeOf respGroup.records[0].getCellValueAsString) returns “Function”

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2022 03:49 PM
Like I showed in my example, you have to actually tell the script which field. .getCellValueAsString("Name or ID of Field")

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2022 03:50 PM
Hmm ok so I was missing the name or id. When I add it, I get a string output, but no string value
output.text(respGroup.records[0].getCellValueAsString(‘NDD - Responsible Group’)) returns nothing

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2022 03:52 PM
Does it return a string or does it return nothing? In scripting those are different.
Does the first record from the view you’re querying have a value for that field?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2022 03:54 PM
The first record does have a value for that field. I can output the table and it gives me all the record IDs and names.
When I use typeOf, it says the output is a string. However, when I use the output.text() function there’s nothing printed in the console. I’m not clear on whether the output is an empty string or something else

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2022 04:10 PM
The first record in the grid view is not necessarily the first record returned in the results.
Try console.log()
instead of output.text()
and post a screen shot of the result. Also include a screen shot of the actual record data from the grid view.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 02, 2022 04:19 PM
Ah that was it! I can read a different index and get a value out. Thank you both! I really appreciate it!
Have a good weekend
