Using object link with named formula

I’m using object link with open window to direct my “users” experience to a section of a page - and it works, except that the formula builder thinks it is an error.

I’m just wondering if this is a bug or a feature?

Hi @Graham_Honeywill1 :blush:

I don’t think this is a bug …

The named formula returns a value … So you’re not pointing to an object “named formula” as a whole but to the value it returns (same goes for controls as far I’ve seen) …
At least, this is how I understand it, as we can use and re-use the value a named formula/canvas control everywhere without to much troubles :blush:

Note that ObjectLink() accept inputs such as tables, columns, rows, and docs not named canvas formula or controls :blush: (even though, it seems to work anyway :sweat_smile: )

I guess, that if you’re bothered by the error the editor it throwing, you could use something like :

OpenWindow("Url_of_the_line_where_the_named_formula_is_sitting")

i am unclear…

what exactly is [Home page area 3] ?

your screenshot does not show how it was defined or what exactly it is.

i am very interested in understanding this because i hate using actual URL values in the OpenWindow() function to navigate the user to a given location in the document.

this is because the URL contains the name of the document. so if the user changes their document name (eg; “CRM v1.0” → “CRM v2.0”) then the links are broken, unless you edit them all.

even worse; if they copy the doc to create “CRM v2.0” and the old doc “CRM v1.0” is left behind, all your OpenWindow() links will send the user to the OLD document, which is VERY confusing for users! since the two documents may be very similar, the bug can go undetected for ages.

so if you have found a way to provide a named reference to OpenWindow() that does not contain the document name, this would be very useful indeed.

max

I’m not a big fan of using URL either as a form of navigation :innocent: (for all the point you mentioned :wink: )

You don’t need to use the doc’s name in OpenWindow() though :blush: : You can use the “shorten version” : https://coda.io/d/_dxxxxxxxxxx/_suyyy#_luzzz where _dxxxxxxxxxx would be the Doc ID, _suyyy would be the page ID (I think) and _luzzz the line ID on the canvas :blush:

If you use the Copy link in the menu at the beginning of a line, it doesn’t seem to return the name of the doc anymore in the link … The name of the page yes, but not the doc :blush:

Testing ObjectLink() earlier, it does seem to open the page where the Coda object used with ObjectLink() is situated without having to use the url … But if the object in question is not from the current accepted list of inputs ( tables, columns, rows, and docs) it lack precision …

Thanks all for your valuable comments. @Xyzor_Max, “Home page area 3” is a named formula on my home page that returns different texts or videos depending on the state of the doc. @Pch, your comments have helped me understand that the URL links are indeed dynamic so I can safely use them in my template and the links remain intact when I create docs from the template … so thank you again

thats excellent to know, many thanks.

sorry, correction. Having replaced all my ObjectLinks with url links, now when I create a doc from my template, the links take me to the location in the template, not to the doc, so I think I have to go back to using ObjectLink, at least until someone can show me otherwise

thank you graham for the clarification.

this is important.
we need to ensure that the links work correctly after the template has been copied to make a new live doc.

teleporting a user into the template instead of the live doc can be a serious problem. it looks identical to the user, but any changes they make appear to vanish afterwards when they open the live doc (because they saved them in the template by mistake).

so best practice is to use ObjectLink()?

can you share an example with us to illustrate how you do that?

max

Apparently if you create a “navigation index” in the template and use that to store the URL that should be opened when clicking on a button, you should be able to stay in the correct doc :blush:

I’ll admit that I don’t remember how this was working before but I think I ran into issues with this …

Here’s what I mean by a “navigation index” in the template

The Page field is a simple text field where I’ve either @ref a page or copy/paste the link to a specific line :blush:

The [Page/Line ID] “extracts” the ID from the Page field using simply thisRow.Page.ToText()
And the [Page URL] field re-creates a the appropriate URL using the Doc ID stored in the named formula (created using thisDocument.ObjectLink().ToText()) above and the [Page/Line ID] with Format()

In my template, I have a button where the action is

OpenWindow(
  [0 - Index].[Page URL]
)

The row [0 - Index].[Page URL] has been directly @ref in there :blush:

If I insert that template into a brand new blank doc, this is what I get …

The various ID’s are different than the ones in the template :blush:

So, the URL’s opened using what’s stored in the field [Page URL] are different too and you should stay within the doc :blush:

I’m absolutely not pushing to use the various ID’s we can have in a doc as a form of navigation, I’d just thought it might be useful to someone, someday… somewhere :smile:

I don’t know how packs works for templates but maybe the Doc Explorer Pack could help for that too :thinking:

1 Like