Page 2 of 3

Re: Subform customization

Posted: Mon Feb 22, 2016 10:37 pm
by admin
Ion2,

Rather than confusing the task by trying to do so many things at once, Try doing (or asking) just one thing.

Then when you understand that you are more likely to figure the rest out.

The more complicated your question less chance I'll get around to asking it quickly.

Steven

Re: Subform customization

Posted: Wed Mar 09, 2016 10:02 am
by amarisJones
I have been concerned about this topic and have been looking for answers. Hoping to find the best solution, we look forward to your sharing. Thank you.

Re: Subform customization

Posted: Wed Mar 09, 2016 11:40 am
by Ion2
Dear amarisJones,

I have decided to use a workaround. There is an other issue by using build-in log-function (http://wiki.nubuilder.net/nubuilderv3/i ... ave_Button) of nuBuilder. My trigger starts with:

Code: Select all

IF NEW.inventory_log_changed_at <> OLD.inventory_log_changed_at THEN
INSERT INTO inventory_log 
Some times in this case the inventory_log_changed_by is still emty after copying into my table inventory_log. The reason seems to be that the log-function writes several times into the table. Therefore I decided to use a workaround:
The key will be the Hash Variables(http://wiki.nubuilder.net/nubuilderv3/i ... _Variables). I want to insert #nu_user_name# into my table prior save by using Form / Custom Code / Before Save.

The code for that should be something like:

Code: Select all

$s = "
    UPDATE inventory
    SET inventory_MODIFIED_by = '#nu_user_name#'
    
";

nuRunQuery($s);
(see also: http://forums.nubuilder.cloud/viewtopic.php?f=4&t=8850)

I have not tried it yet but I keep you updated. Please give feedback, if it worked for you.

Greetings,
Timo

Re: Subform customization

Posted: Wed May 25, 2016 2:31 pm
by Ion2
Hi, this is working:

Code: Select all

$s = "
    UPDATE inventory
    SET inventory_log_modified_by = '#nu_user_name#'
    
    WHERE INVENTRORY_ID = '#RECORD_ID#'
";

nuRunQuery($s);
but I want to put the CURRENT_TIMESTAMP into field inventory_log_modified_at.

These three options do not work:
  • SET inventory_log_modified_at = '#CURRENT_TIMESTAMP#'
  • SET inventory_log_modified_at = CURRENT_TIMESTAMP
  • SET inventory_log_modified_at = NOW()
What is the way to go?

I learned not to interfere with zzzsys_user_log_changed_at.

Greetings,
Timo

Re: Subform customization

Posted: Thu May 26, 2016 3:23 am
by admin
Timo,

I would use Now();

Steven

Re: Subform customization

Posted: Thu May 26, 2016 8:45 am
by Ion2
This ist not working as Custom Code in Before Save:

Code: Select all

$s = "
    UPDATE inventory
    SET inventory_log_TN_modified_by = '#nu_user_name#'
    SET inventory_log_modified_at = NOW();
    WHERE INVENTRORY_ID = '#RECORD_ID#'
";

nuRunQuery($s);
Using NOW(); in the Database only gives me the current date, when inserting a new row into the table. This is not what I want. I want to track the modification date independent from the “XYZ_log_changed_at” system field.

How can I insert the current date by using Custom Code in Before Save?

Thx, Timo

Re: Subform customization

Posted: Tue May 31, 2016 1:57 am
by admin
Timo,

I dont understand your question (does the sql you tried work?)

Steven

Re: Subform customization

Posted: Tue May 31, 2016 4:18 pm
by Ion2
Steven,

the code

Code: Select all

$s = "
    UPDATE inventory
    SET inventory_log_TN_modified_by = '#nu_user_name#'
    SET inventory_log_modified_at = NOW();
    WHERE INVENTRORY_ID = '#RECORD_ID#'
";

nuRunQuery($s);
is not working. I'll get the following Error:
Error.png
Whithout

Code: Select all

    SET inventory_log_modified_at = NOW();
the code is working.

Greetings,
Timo

Re: Subform customization

Posted: Tue May 31, 2016 4:29 pm
by hanstel
use date() before call to you php code

nuSetHash('LogModDate',date());

// then call your php code

...
your-field = '#LogModDate#'
...

Re: Subform customization

Posted: Wed Jun 15, 2016 5:25 pm
by Ion2
Dear Hanstel,

I still didn't get the clue.
hanstel wrote:use date() before call to you php code

nuSetHash('LogModDate',date());

// then call your php code

...
your-field = '#LogModDate#'
...
Is this what you mean?

Code: Select all

nuSetHash('LogModDate',date());

$s = "
   UPDATE inventory
    SET inventory_log_TN_modified_by = '#nu_user_name#'
    SET inventory_log_modified_at = '#LogModDate#'
    WHERE INVENTRORY_ID = '#RECORD_ID#'
";

nuRunQuery($s);
...or that?

Code: Select all

$s = "
   nuSetHash('LogModDate',date());
   UPDATE inventory
    SET inventory_log_TN_modified_by = '#nu_user_name#'
    SET inventory_log_modified_at = '#LogModDate#'
    WHERE INVENTRORY_ID = '#RECORD_ID#'
";

nuRunQuery($s);
Both aren't working for me. Could you give me another hint?

Thx, Timo