Help

Referencing a "Link To Another Record" Field

Topic Labels: Scripting extentions
Solved
Jump to Solution
1840 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Christian_Cook
5 - Automation Enthusiast
5 - Automation Enthusiast

Hello!

I’m trying to edit a script that I already have. To do so, I need to be able to get values from a Link to Another Record. The linked record is on a different table. I’ve been using .getCellValue() for most cases, but it doesn’t seem to be helping me here. Right now, when I run the .getCellValue, it returns an Object, and when I run .getCellValue().values, it outputs “function”.

How can I get a specific field off of the linked record?

1 Solution

Accepted Solutions
AlliAlosa
10 - Mercury
10 - Mercury

Here are two approaches…

  1. You could use a lookup field to pull over the value from the other table - this way it’s already part of the selected record when your script runs.

  2. If you don’t want to do that, you’ll need to select the record on the other table in order to use the getCellValue() method.

If the linked record field you’re referencing only has one value in it (I.e is only linked to one record on the other table), the following code should work for you:

let recordToSelect = selectedRecord.getCellValue("Linked Record Field Name")[0];


let recordFromOtherTable = await otherTable.selectRecordAsync(recordToSelect.id);

let valueFromOtherTable = recordFromOtherTable.getCellValue("Field From Other Table");

The above is drastically simplified but if you want to share more info I’m happy to help you adjust for your code / use case :slightly_smiling_face:

See Solution in Thread

1 Reply 1
AlliAlosa
10 - Mercury
10 - Mercury

Here are two approaches…

  1. You could use a lookup field to pull over the value from the other table - this way it’s already part of the selected record when your script runs.

  2. If you don’t want to do that, you’ll need to select the record on the other table in order to use the getCellValue() method.

If the linked record field you’re referencing only has one value in it (I.e is only linked to one record on the other table), the following code should work for you:

let recordToSelect = selectedRecord.getCellValue("Linked Record Field Name")[0];


let recordFromOtherTable = await otherTable.selectRecordAsync(recordToSelect.id);

let valueFromOtherTable = recordFromOtherTable.getCellValue("Field From Other Table");

The above is drastically simplified but if you want to share more info I’m happy to help you adjust for your code / use case :slightly_smiling_face: