Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global variable can't be used as a filter value if that value is an integer #14198

Open
nskartoredjo opened this issue Jun 29, 2022 · 6 comments

Comments

@nskartoredjo
Copy link

Describe the Bug

At the Insights module, if you want to use a global variable specified by any global variable panel, you won't be able to use it at a filter which requires its value to be an integer.

Take for instance the following example:

Axis.-.Google.Chrome.2022-06-29.21-37-51.mp4

Here, serial (in contrast to product) is an integer, and thus, you won't be able to use {{ serial }}.

To Reproduce

Make sure you have a collection with an integer field. x Next, try to create a panel which uses this collection. Third, create a filter and try to apply a filter x equals {{ var }}. You will see that any string will be ignored here, and thus the value will be discarded, i.e. x equals ....

Errors Shown

No response

What version of Directus are you using?

9.13.0

What version of Node.js are you using?

16.13.0

What database are you using?

Postgres 13

What browser are you using?

Chrome

How are you deploying Directus?

PaaS

@licitdev
Copy link
Member

Variables in filters are wrapped in quotes as such "{{ some_num }}".
However, it has to be parsed as a number when the filter is processed.

@jaycammarano Will the fix for #13943 be related to this issue?

@eikaramba
Copy link
Contributor

in 9.18.0 i still don't know how i can use variables in filters. i just want to filter based on an id. e.g.
user->devices->id equals {{myglobalvariable}}

is this really not possible. i also tried it in quotes, no luck.

@azrikahar
Copy link
Contributor

@eikaramba can you try removing the quotes via the Raw Editor? Here's a quick example:

chrome_bo8OIW6G51.mp4

It should help ensure the filter is against an integer instead of a string.

@eikaramba
Copy link
Contributor

wuhu, that actually worked! Finally, so much power now via insights! 🎉 another entry for my little manual https://fork-appeal-054.notion.site/Directus-Missing-Manual-07cfbb75414b4fcb9401f4325701d61e#e81bb885ecff4e1d8624c515771b8053

@azrikahar
Copy link
Contributor

wuhu, that actually worked! Finally, so much power now via insights! 🎉

Glad that works! Just in case you haven't notice, your use case might also benefit from the Global Relational Variable added via #15452 in 9.18.0 (so you can select a device item via a drawer list).

another entry for my little manual https://fork-appeal-054.notion.site/Directus-Missing-Manual-07cfbb75414b4fcb9401f4325701d61e#e81bb885ecff4e1d8624c515771b8053

Thanks again for maintaining this list 👍 I'm pretty sure this is already in @erondpowell's radar, but tagged him once again just in case. 😄

@rijkvanzanten
Copy link
Member

Linear: ENG-240

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📋 Backlog
Development

Successfully merging a pull request may close this issue.

6 participants