Navigation Hidden menu

  • Goal: student projekt

  • Details: < pls help me how can i hide menu button from student or from instuctors. if the student is in the student table than they can see the button, also for instuctors for other buttons
    this is my DB and table

  • Screenshots:


    FROM student_management.ENROLLMENTS

  • my solution what works in BigQuery but not here
    select
    CASE
    WHEN EXISTS (
    SELECT 1
    FROM AdatBazis.students
    WHERE Email = 'smith.eva@student.uni-pannon.hu'
    ) THEN TRUE
    ELSE FALSE
    END AS EmailExists; --> true

Hi @Lauu :wave:

Welcome to the community!

I understand that you're trying to show/hide a specific element in your application based on a certain condition.

Writing SQL statements in the hidden field will unfortunately not work. You'll have to translate this to a JavaScript expression that resolves to true or false in order to hide the element (Check out Write JavaScript in Retool for more information).

I'd recommend to write the SQL statement in your screenshot as Query (see Read data from SQL databases) and then reference the outcome of that query in the Hidden field of your element.

Good luck!

2 Likes

thank you for the fast answer😊 i will try it.

What i am still doing wrong?:((
I want to hide the menĂź, if the Email is in the student table. But the menu is not hidden if i enter some extra letters in my email.

Hi @Lauu

You’re almost there!

If you write EmailExists_student.data in the hidden field, the autocomplete will guide you to the query output.

You can reference the query output elsewhere in the app using the query's data property.
Read data from SQL databases | Retool Docs

1 Like

I am confused, but thank you you are helping so match.
I think i did it right, but the button is till hidden in all cases, i mean if it's TRUE or FALSE.
with the outout: true
SELECT
CASE
WHEN EXISTS (
SELECT 1
FROM student_management.STUDENTS
WHERE Email = 'Moore.Chloe@student.uni-pannon.hu'
) THEN TRUE
ELSE FALSE
END AS EmailExists;

and output: false
SELECT
CASE
WHEN EXISTS (
SELECT 1
FROM student_management.STUDENTS
WHERE Email = 'Moore.Chloe@student.uni-xx.hu'
) THEN TRUE
ELSE FALSE
END AS EmailExists;

Hi @Lauu ,

So close!

In short you need to reference the output of the query as EmailExists_student.data.EmailExists[0].

If you read up a bit on how SQL queries work and how you can reference them, this syntax will become more clear.

Good luck with the rest of the assignment!

3 Likes

omgggg thank you so match❤️, it is working, and yee i see now the logic.

And thank you, we have to do some improvements still with the assignment:)

2 Likes