Sorting a field linked to another table

I have two tables in my database. One is the primary, the other is linked on one field to the primary. The entries that automatically appear in the linked table field are alphabetical, as that is the nature of the key in the primary. However, these entries are not in alphabetical order, but in order of entry/linking from the primary table.

Is there any way I can sort that one field in the linked table so it lists the records alphabetically, A-Z?

In general, linked fields are displayed according to the order that they are stored internally. However, depending on how you access the linked records (directly in the linked record or via a formula), sometimes the records are displayed first-to-last and at other times they are displayed last-to-first.

You can manually change the order of linked records after they are already linked, but that is a huge pain.

It is also possible to change the order of linked records in a script using scripting block.

That’s pretty much what I thought ;-). Can you direct me to where I can find instructions on building a script/scripting block?

Thank you.

The support page for Scripting block has a lot of information.

You can also look at my script for finding the first/last linked record for help.

You also need to know JavaScript to write a script.

Great — thanks kuovonne

@11131

You can also use the Batch Update block if you have a Pro subscription. (Sorry I forgot about it before. I’ve been working with Scripting block a lot recently, and my thoughts tend to automatically go there first.)

It looks like this inconsistent behavior is about to become more consistent. There is now a new toggle option for the order of linked records. This option will exist for bases created before April 2020 (basically all bases currently in existence) as part of a migration to the new, more consistent display.

(The order of record links will still be based on the order in which the links are stored, not in order of a field value.)

Awesome improvement! Thanks for letting me know – I hadn’t gotten around to scripting yet, and now won’t need to.

While it is a good improvement, it won’t actually help you get an alphabetical sort.

Your best bet is still the Batch Update block, unless you are on a free plan and feel comfortable writing a script (or hiring someone to write a script).

It does give me an alphabetical sort on the linked field — but only on my desktop. The toggle option is not available, apparently, in the mobile app.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.