Hello,
I am creating a simple time sheet application. 1 master table with a few lookup tables. What I am struggling with is getting the Timesheet Browse&Edit form to only show the current users logged times.
Any assistance would be appreciated.
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Browse&Edit form to only show the current users information
-
- Posts: 7
- Joined: Mon Jul 13, 2020 4:23 pm
Browse&Edit form to only show the current users information
You do not have the required permissions to view the files attached to this post.
-
- nuBuilder Team
- Posts: 4307
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 448 times
- Contact:
Re: Browse&Edit form to only show the current users informat
Hi,
I would do it like this:
When saving the form, you store the user id in a field/db column (e.g. user_id)
In the form's custom code, add this JS:
In the Browse SQL, add a Where clause like
WHERE user_id = '#USER_ID#'
Let me know if you need more details.
Edit: Here's a more secure way to achieve that: https://github.com/smalos/nuBuilder4-Co ... o_own_data
I would do it like this:
When saving the form, you store the user id in a field/db column (e.g. user_id)
In the form's custom code, add this JS:
Code: Select all
function nuBeforeSave() {
let userId = nuCurrentProperties().user_id;
$("#user_id").val(userId).change();
return true;
}
In the Browse SQL, add a Where clause like
WHERE user_id = '#USER_ID#'
Let me know if you need more details.
Edit: Here's a more secure way to achieve that: https://github.com/smalos/nuBuilder4-Co ... o_own_data
Last edited by kev1n on Sun Jul 19, 2020 4:18 pm, edited 2 times in total.
-
- Posts: 7
- Joined: Mon Jul 13, 2020 4:23 pm
-
- Posts: 4
- Joined: Mon Aug 24, 2020 11:16 am
Re: Browse&Edit form to only show the current users informat
Hi,
I am using the
"Edit: Here's a more secure way to achieve that: https://github.com/smalos/nuBuilder4-Co ... o_own_data" solution.
And my case is a little more complicated. And the current USER_ID value is not going into the field in the table. Can you please help me? Thank You!
It is a browse and edit form. it joins table device_list with group_list (a lookup table), so that the group_desc can be displayed with other fields from device_list.
I follow the above solution. All goes well, but the current USER ID value is not filled into the user_id of device_list.
I am using the
"Edit: Here's a more secure way to achieve that: https://github.com/smalos/nuBuilder4-Co ... o_own_data" solution.
And my case is a little more complicated. And the current USER_ID value is not going into the field in the table. Can you please help me? Thank You!
It is a browse and edit form. it joins table device_list with group_list (a lookup table), so that the group_desc can be displayed with other fields from device_list.
I follow the above solution. All goes well, but the current USER ID value is not filled into the user_id of device_list.
You do not have the required permissions to view the files attached to this post.
-
- Posts: 4
- Joined: Mon Aug 24, 2020 11:16 am
Re: Browse&Edit form to only show the current users informat
follow the solution https://github.com/smalos/nuBuilder4-Co ... o_own_data
You do not have the required permissions to view the files attached to this post.
-
- nuBuilder Team
- Posts: 4307
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 448 times
- Contact:
Re: Browse&Edit form to only show the current users informat
Hi,
Use nuHasNoRecordID() instead of nuHasNewRecordID().
In AS, add
and check the nuDebug Results to see what the generated SQL looks like.
Use nuHasNoRecordID() instead of nuHasNewRecordID().
In AS, add
Code: Select all
nuDebug("UPDATE device_list SET user_id = '#USER_ID#' WHERE device = '#RECORD_ID#' ");
-
- Posts: 49
- Joined: Wed Aug 26, 2020 10:38 pm
Re: Browse&Edit form to only show the current users informat
Hi, I'm trying to use this function and the user_id field in my table is always null. So when logged in as a user, not globeadmin, the browse is empty. I can see the zzzzsys_user_id is there. But this php is not adding the user_id to my "client" table.
Here's what I'm seeing:
Here's what I'm seeing:
You do not have the required permissions to view the files attached to this post.
-
- Posts: 49
- Joined: Wed Aug 26, 2020 10:38 pm
Re: Browse&Edit form to only show the current users informat
I think I fixed it. The github page says to use "nuHasNoRecordID" but the Discord code library says to use nuHasNewRecordID". the latter worked for me.