Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Logging the User ID

Questions related to using nuBuilder Forte.
Post Reply
marcus
Posts: 20
Joined: Mon Nov 29, 2021 10:16 am

Logging the User ID

Unread post by marcus »

Hi there, I have a subform and want to log the User ID to be written autmaticly in one of the fields when creating an entry. How can I achieve this?

Best regards
marcus
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Logging the User ID

Unread post by kev1n »

Hi,

Add a varchar(1000) starting with the table's name followed by _nulog, to a table and nuBuilder Forte will start automatically logging activity to each record in that table.

https://wiki.nubuilder.cloud/index.php? ... g_Activity
marcus
Posts: 20
Joined: Mon Nov 29, 2021 10:16 am

Re: Logging the User ID

Unread post by marcus »

Hi adn thanks a lot, that is pretty handy!
Is there any pre-made way to just extract the creating user or creating time for example (like a function)?
Otherwise I will write my own query.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Logging the User ID

Unread post by kev1n »

Check out the code library.
marcus
Posts: 20
Joined: Mon Nov 29, 2021 10:16 am

Re: Logging the User ID

Unread post by marcus »

Hey, thanks
I dont know how I can display the values added_user, added_time, edited_user, edited_time inside the subform, do you know how i can achieve this?
My Browse SQL Statement is

Code: Select all

SELECT
    order_comment_id,
    order_comment_order,
    order_comment_text,
    added_user,
    added_time,
    edited_user,
    edited_time
FROM 
(   
	SELECT  	
		order_comment_id, order_comment_order, order_comment_text,
		JSON_UNQUOTE(JSON_EXTRACT(order_comment_nulog, '$.added.user')) as added_user,
		FROM_UNIXTIME(JSON_EXTRACT(order_comment_nulog, '$.added.time')) as added_time,

		JSON_UNQUOTE(JSON_EXTRACT(order_comment_nulog, '$.edited.user')) as edited_user,
		FROM_UNIXTIME(JSON_EXTRACT(order_comment_nulog, '$.edited.time')) as edited_time	
	FROM order_comment
) T
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Logging the User ID

Unread post by kev1n »

You could use Display objects for that.
marcus
Posts: 20
Joined: Mon Nov 29, 2021 10:16 am

Re: Logging the User ID

Unread post by marcus »

Could you please point me in the right direction here?
In a display object inside the subform I tried

Code: Select all

SELECT '#added_user#'
And the output is #added_user#, so it seems like the hash cookie isnt existing
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Logging the User ID

Unread post by kev1n »

For each display object, you need to select the corresponding nulog field for that row. E.g.

Code: Select all

SELECT  	
  JSON_UNQUOTE(JSON_EXTRACT(order_comment_nulog, '$.added.user'))
FROM order_comment
WHERE order_comment_id = '#RECORD_ID#'
Post Reply