users and roles

85 views
Skip to first unread message

Moh. Sarip Hidayat

unread,
Jan 20, 2024, 2:38:08 PM1/20/24
to Jam.py Users Mailing List
Hi, I would like to access the admin database to get information about users and roles.
I need this to build report (show who is the creator of the entry and who is printing it, which not always the same) and apply hidden filter based on roles. I was trying to access those tables like normal item/task but It isn't working.

For example, this one is working for accessing normal item/task:

    var table = item.task.item_by_ID(parseInt(6)).copy();
    table.open({fields: ['customer_name'], where: {id: 1}});
    table.each(function(c){console.log(c.customer_name.value);});


But I can't access the user and role item/task which is having ID of -3 and -2 respectively.

I understand that there is tutorial on how to use separate table for users but it is
  1. Lack of information on how to handle roles
  2. I prefer using the frameworks default capabilities as much as possible to reduce customization
Thanks!

Dean D. Babic

unread,
Jan 20, 2024, 11:15:39 PM1/20/24
to Jam.py Users Mailing List
Hi,
not quite sure the meaning of "normal item/task" and -3 and -2, but the info is in Task/Client on Demo:
   if (task.safe_mode) {
        $("#user-info").text(task.user_info.role_name + ' ' + task.user_info.user_name);

Not sure if that helps tho.
D.

Moh. Sarip Hidayat

unread,
Jan 21, 2024, 12:42:30 AM1/21/24
to Jam.py Users Mailing List
Hi, thank you for your reply.

I also stumbled on this part but unfortunately this is not what I needed. This part is only good to extract information of current user login.
What I need to do is query user and role information based on the id. I put information about who created an entry in a journal, in column created_by, containing value of the task.user_info.user_id. How can I get the user_name and role_name? Again, task.user_info.role_name or task.user_info.user_name only good for current user login.

If no official way to do this then I guess I will have to access the admin.sqlite from server module.

Thanks.

Dean D. Babic

unread,
Jan 22, 2024, 2:34:59 AM1/22/24
to Jam.py Users Mailing List
 Roles are just a lookup, so with your_auth_table.rolename.display_text you would get the role name.

The same is for above, if you storing user_id AND role_id in the journal as a lookup, the display_text would give both I think.

Dean D. Babic

unread,
Jan 22, 2024, 2:37:07 AM1/22/24
to Jam.py Users Mailing List
Plus, if storing only created_by, and not the role, what happens when the role is changed for the user?
So, your report would not be correct over time if the role was changed.

Moh. Sarip Hidayat

unread,
Jul 5, 2026, 7:25:42 AM (12 days ago) Jul 5
to Jam.py Users Mailing List
Hi everyone

Today I learned that we could query the admin.sqlite data from within our jam.py project!

Example to check if the Application builder → Project → Parameters → Production flag is ticked on from a server module:
d = item.task.app.admin.task.sys_params.copy()
d.open()
print(f'Application builder → Project → Parameters → Production: {d.f_production.value}')

So if someone needs to access the users table, they can work with item.task.app.admin.task.sys_users.
Likewise, for the roles table they can work with item.task.app.admin.task.sys_roles.

And we actually had it hinted here by Andrew. 

I wish I discovered this long ago!

Thank you.

Best Regards,
Moh. Sarip Hidayat
Visit my website at musahi0128.github.io


--
You received this message because you are subscribed to a topic in the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jam-py/MHFbzRUhQbw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jam-py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jam-py/4294cdd2-1758-44a0-bc0e-fc75b1a39490n%40googlegroups.com.

Dean D. Babic

unread,
Jul 6, 2026, 5:55:22 AM (12 days ago) Jul 6
to Jam.py Users Mailing List
Glad you fixed it!
Thanks
Reply all
Reply to author
Forward
0 new messages