Use another column data in URL

Hey all - I am trying to use an Entity Key/ID as part of a URL on another field = eg HTTP://somesite/{{entitykey}}.
The only way I can get the variable to appear is to ensure the entity key is viewable as a column. If I remove it the URL simply becomes HTTP://somesite/.
I have trawled through the list of issues and tried searching for this issue, but didn't have any luck.
Thanks.

Hi @amosm
Post "Diagnostic Info" from Admin > Troubleshooting.
If you are not using the latest release, then upgrade: https://github.com/metabase/metabase/releases/latest

{
"browser-info": {
"language": "en-US",
"platform": "Win32",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36",
"vendor": "Google Inc."
},
"system-info": {
"file.encoding": "Cp1252",
"java.runtime.name": "Java(TM) SE Runtime Environment",
"java.runtime.version": "1.8.0_311-b11",
"java.vendor": "Oracle Corporation",
"java.vendor.url": "http://java.oracle.com/",
"java.version": "1.8.0_311",
"java.vm.name": "Java HotSpot(TM) 64-Bit Server VM",
"java.vm.version": "25.311-b11",
"os.name": "Windows Server 2019",
"os.version": "10.0",
"user.language": "en",
"user.timezone": "Australia/Sydney"
},
"metabase-info": {
"databases": [
"h2",
"sqlserver"
],
"hosting-env": "unknown",
"application-database": "h2",
"application-database-details": {
"database": {
"name": "H2",
"version": "1.4.197 (2018-03-18)"
},
"jdbc-driver": {
"name": "H2 JDBC Driver",
"version": "1.4.197 (2018-03-18)"
}
},
"run-mode": "prod",
"version": {
"tag": "v0.41.2",
"date": "2021-11-09",
"branch": "release-x.41.x",
"hash": "ad599fd"
},
"settings": {
"report-timezone": "Australia/Victoria"
}
}
}

@flamber - does that tell you anything?

@amosm
The columns you want to include in the URL has to be part of the results.
So you would either need to create a Custom Column, or hide the column on the dashboard card, which only hides the column while still keeping it as part of the results.

You should upgrade to Java 11:
https://www.metabase.com/docs/latest/operations-guide/java-versions.html
And migrate away from H2 if you're using Metabase in production:
https://www.metabase.com/docs/latest/operations-guide/migrating-from-h2.html

The columns are included as per the images below. I will look at moving Java and moving to production DB too.


No change with Java. Will look at DB tomorrow:

{
"browser-info": {
"language": "en-US",
"platform": "Win32",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36",
"vendor": "Google Inc."
},
"system-info": {
"file.encoding": "Cp1252",
"java.runtime.name": "OpenJDK Runtime Environment",
"java.runtime.version": "11.0.13+8",
"java.vendor": "Eclipse Adoptium",
"java.vendor.url": "https://adoptium.net/",
"java.version": "11.0.13",
"java.vm.name": "OpenJDK 64-Bit Server VM",
"java.vm.version": "11.0.13+8",
"os.name": "Windows Server 2019",
"os.version": "10.0",
"user.language": "en",
"user.timezone": "Australia/Sydney"
},
"metabase-info": {
"databases": [
"h2",
"sqlserver"
],
"hosting-env": "unknown",
"application-database": "h2",
"application-database-details": {
"database": {
"name": "H2",
"version": "1.4.197 (2018-03-18)"
},
"jdbc-driver": {
"name": "H2 JDBC Driver",
"version": "1.4.197 (2018-03-18)"
}
},
"run-mode": "prod",
"version": {
"date": "2021-11-09",
"tag": "v0.41.2",
"branch": "release-x.41.x",
"hash": "ad599fd"
},
"settings": {
"report-timezone": "Australia/Victoria"
}
}
}

@amosm The recommendations about Java and H2 will not change anything about this. It's just recommendation for a healthier system.

You are showing the query browser, which will remove the field from the results if you exclude it there.

You can only do this by hiding the column, either via the dashboard card visualization options or by hiding the column via the Admin > Data Model:
https://www.metabase.com/docs/latest/administration-guide/03-metadata-editing.html#column-visibility

Hiding via Admin > Data Model didn't work. Have resorted to removing it via the Dashboard viewing option of the question. Thanks.

@amosm Did you set it to "Only in Detail Views" and then try to create a new question for that table? That should work. But if you manually add the column, then it overrides the original hiding.

@flamber had set to Detail View only and also Do not include - still does not work on a completely new question. It is currently an int field, but I also tried originally passing the URL via the SQL view, but that made no difference.

@amosm Okay, I guess you're doing something that I cannot reproduce. When using SQL, then the columns in the select-clause are always included in the results, so using the visualization settings will just hide the column.

1 Like

Hi there,

I am having the same issue. I tired with (i) column title, (ii) SQL import name, and (iii) name provided by Metabase and it did not work.

Was this solved?

Thanks

@Enrico.Magnani
Post "Diagnostic Info" from Admin > Troubleshooting.
I don't know what "SQL import name" means, but there was no issue, so nothing to resolve. If you are having problems, then show screenshots of exactly what you are trying to do. Please make sure you have read every single post in this thread.
Upcoming versions will show a dropdown selector, which makes it easier to select variables.

Hi @flamber , I am sorry but it doesn't seems to be solved. Maybe I am misreading.

Anyway, I am trying to create a dynamic link ad I am not sure what to use for the variable {{column}}, considering that is data imported from a table I joined.

In the picture I numbered the 3 options I listed in my previous comment.

Capture

the "SQL import name" is the name attributed to the column if I look a the SQL query.

I hope it makes sense. Thanks for helping!

@Enrico.Magnani You are using GUI editor, which makes it difficult to understand what the actual column references are underneath, but it is likely {{id_2}}

2 Likes

Thanks @flamber {{id_2}} works!

Wow, this information took me MONTHS to find!

1 Like

It feels like the GUI editor should expose the column references somehow for use cases like this where they need to be used. I think the duplicate column names can also cause problems when doing multiple joins on the same table (e.g. to deduplicate values, etc)