Page 1 of 1

Logging the User ID

Posted: Fri Feb 04, 2022 9:46 am
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

Re: Logging the User ID

Posted: Fri Feb 04, 2022 9:48 am
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

Re: Logging the User ID

Posted: Fri Feb 04, 2022 9:54 am
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.

Re: Logging the User ID

Posted: Fri Feb 04, 2022 9:59 am
by kev1n
Check out the code library.

Re: Logging the User ID

Posted: Sat Feb 05, 2022 9:24 am
by kev1n

Re: Logging the User ID

Posted: Mon Feb 07, 2022 10:29 am
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

Re: Logging the User ID

Posted: Mon Feb 07, 2022 11:43 am
by kev1n
You could use Display objects for that.

Re: Logging the User ID

Posted: Mon Feb 07, 2022 12:11 pm
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

Re: Logging the User ID

Posted: Mon Feb 07, 2022 12:31 pm
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#'