Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
Hi guys!
I want to fill select box which list all username from Users. So,whenever i delete one username from Users automatically it does not appear at select box. I try to make query ("Select username from.....")..but I stuck at from because i don't know what table for Users.So,where can I locate database like User so that I can make query to retrieve record to fill select box?
Thanks.
13 Comments
Owen Ong
Hi Sarah,
Users are store in dir_user table.
Hope this's help.
Owen
sarah
Thanks Owen. I try it first.
sarah
Hi guys!
Below are codes to fill select box with username from dir_user. However, username are not appear at select box even i try make a query which select all username and use FormRow to list it at select box. Anyone can guide if I should make some changes to these codes?
import java.sql.*;
import java.util.*;
import org.joget.apps.form.model.*;
import org.joget.apps.form.service.*;
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost:3307/sampledb?useUnicode=true&characterEncoding=UTF-8", "root", "");
if(!con.isClosed()){
PreparedStatement stmt = con.prepareStatement("("SELECT *
FROM dir_user WHERE username=" ")");
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
public FormRowSet user_rec()
return user_row;
}
return user_rec;
}
}
} catch(Exception e) {
System.err.println("Exception from BeanShell activity: " + e.getMessage());
} finally{
try
catch(SQLException e) {}
}
return "1";
Hugo
Hi Sarah,
You can actually achieve this by using the Form Options Binder to DirectoryManager (User, Group, Department, Organization) binder. I have fixed your codes as well. Try the following one.
PS: Try to use code block macro when you embed codes in here next time.
sarah
Hi Hugo!
I had tried the codes that you fixed,still not working. Username still not fill in the select box. Besides that, I'm just a beginner and for starting I used Joget Workflow v3 Community Edition.. :-). Or I need to add:
Owen Ong
Hi Sarah,
I just tested the code provided by Hugo. It's work.
You just need to copy and paste the code to Bean Shell Form Binder and put the correct database connection will do.
I think you may be put the wrong database name. Default database should be jwdb.
sarah
Thank you very much! It works!
sarah
Hi everyone!
If I used (SELECT * FROM dir_user) or (SELECT id,username FROM dir_user), it runs perfectly. However, if I use (SELECT username FROM dir_user) or (SELECT id,firstName FROM dir_user), it doesn't work. May I know why? Or is it related to key table which is "id" and sort by "username"?
Thanks.
Owen Ong
Hi Sarah,
In the code below, it expect at least 2 columns selected in your query. So, first column will be used as Label and second column will be used as Value.
I tested with the below query that you used, it is working.
sarah
Oh, really thanks. It works!
sarah
Hi guys!
I have a problem here. After submit form to user (choose username from select box), the user will get the email.
And I used email tools which map tool to plug in. The problem is email can't send out. I've used #performer.activityDefId.email# but it doesn't work. However, I questioned myself, I want to send email to the user. Can anyone helps me?
Hugo
Hi Sarah,
Please try to post in appropriate topic. This would be confusing for others to navigate. Thanks.
Dinx
hello, i got one question here. How to write the code if i want the firstName according to which department there are placed? For example ICT department, the select box just show up firstName of user in ICT department.. really appreciate your feedback.
Beginner Dinx