Preset User name in textField - Cuba7

Hi,

Is there any possibility when I open the User Editor screen to appear the name of the user in textField name?
Let say I have user login name: John

<layout expand="scrollBox" spacing="true">
        <scrollBox id="scrollBox" spacing="true">
            <form id="form" dataContainer="userDc">
                <column width="250px">
                    <textField id="nameField" property="name"/> 

Hi,

You can inject the UserSession bean, obtain the current user and set the user name value to the TextField.

Gleb

So easy. Thank you!

Meantime I created a Service in order to get the user list:

TypedQuery<User> query = em.createQuery("select u.login from sec$User u", User.class);
List<User> users = query.getResultList();

Is there any possibility to extract current user from the above list?

Sure

TypedQuery<User> query = em.createQuery("select u from sec$User u where u.id <> ?1", User.class);
query.setParameter(1, currentUSer.getId());
List<User> users = query.getResultList();
1 Like

Thank you, but currentUser stays in red.
Is there any possibility to inject it somehow?

currentUser is the name of the variable that contains the current user, e.g. obtained using the UserSession bean.

I think is:

userSessionSource.getUserSession().getId())

and why <>?1 and not =?1

Yeah, my mistake. Anyway it seems redundant to execute a query to obtain the current user if at the moment of execution you’ll have the current user.

1 Like