PSA: Link to recently created rows by UID, not RowID()

Requirement: with a button create a row and bring it up into focus (e.g. as a modal)

Problem: to bring out a row into focus, you need its RowID() so that you could construct its URL like:

OpenWindow(Format("#_tu9Wb/r{1}&modal=true", CreatedRow.RowID())

However, RowID() at this point may still be blank because the row is not yet stored to the server. And it will always stay blank if the doc is used in Play mode.

Solution: instead of RowID() use “true” 10-alphadigit unique row ID (UID) that is created on browser side as soon as the row itself is created.

One idiom to get this UID is by formula:

Split(thisRow + "", "/").Last()

The thisRow + "" returns grid-xxxxxxxxxx/i-xxxxxxxxxx table/row UID pair (which, I believe, is used internally to compare row references against each other), and we use Split("/").Last() to only cut off the row UID part.

Now you can use this identifier right away in your URLs.
Heads up: instead of r<RowID> parameter you’ll have to use ru<UID>, like:

OpenWindow(Format("#_tu9Wb/ru{1}&modal=true", CreatedRow.UID)

so that instead of /r123 your link looks like /rui-12345XzYuW.

E.g. here’s a button that creates a “helper table” row if it doesn’t exist (I’m using a helper table as a form to submit cross-doc updates), and immediately opens it as a modal:

This is one of the pro-tips that let you build docs that feel a lot like apps. There’ll be many more like this one on :slight_smile:

P.S. Updated one of my older demos. Play around with this embedplay: create rows and see how UIDs are added immediately and row IDs are not. Then click the “Pop me up” button and see that popups by UID work just fine :slight_smile:


That’s awesome!! keep them going :fire:

Peculiar behavior fact: links with UIDs don’t always work. There’s one case when they don’t:

  • When UID contains an underscore _
  • AND RowID is already present

If both of these conditions apply, the link with /rui-xxxxxxxxxx will not properly convert to a canonical row link with Row ID like it usually does. When there’s no underscore or there’s no RowID yet, it will always work.