When building a URL for a record in a formula field, you need to know the base ID and the table ID. However, when you duplicate the base, the base ID and table ID change, which can break your formula.
While there is no way to get a base ID in a formula, there actually is a roundabout way to get a table ID in a formula.
Overview
When you create a button field that opens an extension, the value for the extension is a URL that contains the URL of the record, which includes the table ID. You can then use a formula field to extract the table ID from the value of the button field.
Add an extension
Add an extension to a dashboard. The most convenient extension is Page Designer. You can configure the Page Designer extension to use the table in question, but the actual table does not really matter. I like to add static text that explains that the extension is being used to extract the table ID.
Create a button field
Create a button field that opens the extension.
Extract the table ID using a formula field
Create a formula field that references the button you just created. You can see in the preview that the formula value includes the table ID.
Build out the formula to extract only the table ID from the value.
This formula uses regular expressions to extract the table ID. It looks for a string that starts with tbl followed by one or more word characters.
REGEX_EXTRACT({Open in Page Designer}, "tbl\\w+" )
Here are the button field and the formula field in a grid view.