Is Username already in the data base?

0
context: I need to check if at the moment of creation of a new account, the username value is already in the database. I am using the marketplace modules>user management>account_new pop up page form.    I modify the “SaveNewAccount” microflow already stablish in the save button and I add a retrieve of all the user from the database  (this is the attribute were the username is saved) and then I add a , “Find” list operation were I use member Name and in equal I’m not sure which expression should I use for checking a value that I just punt in the form.   as a resume: need to check if the username (Name attribute) is in the database already
asked
6 answers
2

Hi Constanza,

As per my understanding username (name) field is there in system module of Mendix project,
there if you check, it already has a validation rule that name should be unique.






If you are building something custom you can also try to do it in the similar way and have validation rule on entity level for uniqueness.


Hope this helps!
Sunit Kumar Dubey

answered
0

Hi Constanza,

I assume you don't use the userlist anywhere else in your flow? If this is the case, you can add a XPath to the retrieve [Name = $ValueToCheck] and only retrieve first. In the split you can check whether a user is found.

The $ValueToCheck should be the username you filled on the form, I guess you can pass this as input parameter?

 

Hope this helps!

answered
0

so I did this and works like well, also in the decision later I use $UserList= empty

 

answered
0

 

Sunit, you just use it in the validation section of the username field?

 

 

answered
0

Hi Constanza ,

If you have a entity validation already , actually you do not need to implement it again in the microflow ,
As , while saving the data Mendix will do the check automatically.

I will suggest you try to add two accounts with same username and just do not modify the default page or microflow ,
you will still see the validation message on the username if it is not unique as it is defined on the entity level.

Please try it out and let me know in case of any doubt.

Regards,

Sunit Kumar Dubey

answered
0

Hi,

please find the below screen shot, it might help you.

 

The save microflow will be having a parameter where the name is Store ( The value which is set to name in the account entity). Add a retrieve from the database and select range as first and add your xpath and validate again the name attribute. In your Decision, you can just check if the object if empty or not.
if the retrieve yields a value the name already exits. 

Hope this helps you.

answered