Remove user from DB in a click

How can I make a button that when is pressed it deletes the user written in the Input form, from DB?

Example:
Input:
[email@email.com]

Button:
{Delete}

That one is easy:
You just simply do a search of any user whose email is equal to the value in the input.
this is the set up:

1 Like

I’m sorry. The point is I can’t find “Delete User” in “Account” or “Data (things)”.

Where you got it from?

screenshot

in the section “Data (things)” —> Delete thing —>Choose user type —> Search for user with same email :slight_smile:

Thank you very much. This makes sense now. But I don’t understand why “:firstitem” must be written.
I can’t get this.

What about if I can’t find user in DB: show popup “User not found”?

I tried to do: only when Input A’s value is … ???
I’m stuck in here.

the search gives as result a list of the object in which the search is being doing, that’s why you need to append the “:firstitem” because it will select the first item of that list received. In this case should be a list with only one value (the user with that email).

If you want to action something when a user is not found using the email input, you just need to create your show popup action with this conditional:

only when -> Do a search of users (whose email = input A):first item is empty

1 Like

Oh my gosh, now something really strange is happening.

When I click that button, and I go in DB I can still see the user. I did refresh, yes.
I can still log in. So it doesn’t go away!

Use the debugger to check if the search is indeed getting the correct user to delete him :slight_smile:

It is getting the correct user.

Why?! Makes no sense at all. The user is in the DB.

that’s odd, send me the link of your app and I will check it right away :slight_smile:

oh right, your issue was that you put some privacy rules that weren’t allowing the current user to get any result from any object “User” search, so the app wasn’t getting the list of users to try to find the one with the same email than the input.

I take out the privacy rule and is now working properly. It’s important to have this privacy rules set properly, otherwise workflows may not work, or data can be exposed to users who shouldn’t see it :slight_smile: