@Kim_Trager1 Yes, you can access the id from the linked record cell value, like so:
let linkedRecordCellValue = record.getCellValue('Linked record field');
// If the cell is empty, getCellValue returns null
let linkedRecordId;
if (!linkedRecordCellValue) {
linkedRecordId = null;
}
// If you know there's only one linked record per cell, it's the id of the first item
linkedRecordId = linkedRecordCellValue[0].id;
// If there can be multiple linked records per cell, you can create an array of ids instead
let linkedRecordIds = linkedRecordCellValue.map(linkedRecord => linkedRecord.id);
It looks like you’re already doing this in the last part of your snippet — does that not output the IDs you’re looking for?
@Kim_Trager1 Yes, you can access the id from the linked record cell value, like so:
let linkedRecordCellValue = record.getCellValue('Linked record field');
// If the cell is empty, getCellValue returns null
let linkedRecordId;
if (!linkedRecordCellValue) {
linkedRecordId = null;
}
// If you know there's only one linked record per cell, it's the id of the first item
linkedRecordId = linkedRecordCellValue[0].id;
// If there can be multiple linked records per cell, you can create an array of ids instead
let linkedRecordIds = linkedRecordCellValue.map(linkedRecord => linkedRecord.id);
It looks like you’re already doing this in the last part of your snippet — does that not output the IDs you’re looking for?
Thank you @Stephen_Suen, I think i wrote my question a little too fast.
What I’m having problems with is figuring out how to check the ID’s of the linked records in reportRecordsForPerson variable, which is an array of objects.
Instead of using having to relly on lookups to check the ID’s of the linked records, I want to have an array of all the id’s of my filtered linked records, so I can check that
let personID === nameRecord.id
I’m not sure if my question makes sense?
I can’t wait to get better at this!
Thank you @Stephen_Suen, I think i wrote my question a little too fast.
What I’m having problems with is figuring out how to check the ID’s of the linked records in reportRecordsForPerson variable, which is an array of objects.
Instead of using having to relly on lookups to check the ID’s of the linked records, I want to have an array of all the id’s of my filtered linked records, so I can check that
let personID === nameRecord.id
I’m not sure if my question makes sense?
I can’t wait to get better at this!
Initially you wanted to check based on name (“Dan”) instead of record ID. If you still want to do that, you can.
In the array for the linked records, just get the .name instead of the .id.
let personName = "Dan";
let linkedRecordName = linkedRecordCellValued0].name;
if (personName == linkedRecordName) {
// it's a match
}
Initially you wanted to check based on name (“Dan”) instead of record ID. If you still want to do that, you can.
In the array for the linked records, just get the .name instead of the .id.
let personName = "Dan";
let linkedRecordName = linkedRecordCellValuea0].name;
if (personName == linkedRecordName) {
// it's a match
}
Thanks @kuovonne I think what I’m wondering if I can reach into another table via the linked field - a bit like a look up?
Thanks @kuovonne I think what I’m wondering if I can reach into another table via the linked field - a bit like a look up?
I don’t quite understand your question.
A linked record field stores only the name and id of the linked record.
To get info from other fields in the linked record, you have to do a .selectRecordsAsync() on the other table and find the record you wanted.
I don’t quite understand your question.
A linked record field stores only the name and id of the linked record.
To get info from other fields in the linked record, you have to do a .selectRecordsAsync() on the other table and find the record you wanted.
I see.
I think that answers my question, I somehow thought that I could access fields in the the other table via the link a bit like a lookup.
But makes sense that it only stores Name and ID