Show a filed conditionnaly during a role creation : Based on the role selected

0
Hi, I added a field in the Account table of the Administration module’s model, and I would like this field to appear only if the selected role that we are creating is, let’s say ‘manager’, which is one of the roles that I defined in the app. But the problem is that I can’t access the value selected in the reference selector “User Roles” (Attribute UserRoles/UserRole/Name). How could I access to it ?  Thank you for the help, Dan
asked
7 answers
1

Sorry, you can only use it in an xpath retrieve. 

 

What you can do is:

- Retreive the manager role in the Onchange microflow (see image above)
- Retrieve all roles by association from the account parameter (which will give back a list of the selected user roles)
- Use list operation contains to check if the manager userrole is in the list. 

Contains will give back a boolean which you can use to set the isManager boolean. 

answered
1

You can add a boolean (if you have only this situation, otherwise you can maybe better use a enum) isManager to the Account entity. Then set an onchange on the rol selection. In the onchange microflow, you can check if the manager rol is selected and if so, set the isManager boolean to true.

Then you can make the extra field visible based on the new boolean. 

answered
0

@Sander, 

I tried your solution but I don’t manage to retrieve the rolename with the command you propose. The only possibilities that I have are there : 

answered
0

I put you screens over here of what I tried : 

 

The real role name is ‘CUW’ : Below the microflow that tests if it is selected by the user.

 

 

 

 

Could you let me know if it was what you meant @Sander ? With this microflow, the field is never displaying (so the isCUW variable stays to false anyway apparently).

answered
0
  • Can you confirm that the onchange microflow is called?
  • And does the “Role = CUW” split always returns false (check with debugging)?
  • Can you compare the objects manually (using the debugger)? Are they the same? Check by id. 
  • Are you really changing the boolean in the change action? 
  • Did you enable refresh in client in the Change action?
  • Is the conditional visibility set right for the element you want to show?

 

(And instead of using “$Flag = true” you can just use $Flag when check if a boolean is true.)

 

answered
0

Hi Sander, 

Here are my answers to your questions : 

The “onchange” microflow is called on the field “User role”, since it is by changing it that I want the field “Hub” to appear

 

And here is the Microflow : as you see I change the attribute “isCuw” depending on the flag value, by doing a commit & refresh in client (icons show it).

 

Even when I put a breakpoint, I don’t manage to debug since the program doesn’t stop after a change on the field (I don’t understand why exactly).

I guess that it has something to do with the “Role = CUW”, my flag is presummably always false as you guess, but I don’t know why. I’ll give you other screens to show you what I do in the microflow : 

 

Finally, here is the condition used : 

answered
0

By the way if someone knows, I have a quite similar problem with a button that I try to make disapear in a list view, but when I do it and activate the “Refresh in client” in my change action of the boolean variable, the list view is charging indefinitely…

The ticket is over there : https://forum.mendix.com/link/questions/93748

 

answered