Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Subform customization

admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Subform customization

Unread post 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
amarisJones
Posts: 1
Joined: Wed Mar 09, 2016 4:00 am
Contact:

Re: Subform customization

Unread post 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.
Ion2
Posts: 41
Joined: Mon Jan 18, 2016 3:01 pm

Re: Subform customization

Unread post 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
Ion2
Posts: 41
Joined: Mon Jan 18, 2016 3:01 pm

Re: Subform customization

Unread post 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
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Subform customization

Unread post by admin »

Timo,

I would use Now();

Steven
Ion2
Posts: 41
Joined: Mon Jan 18, 2016 3:01 pm

Re: Subform customization

Unread post 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
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Subform customization

Unread post by admin »

Timo,

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

Steven
Ion2
Posts: 41
Joined: Mon Jan 18, 2016 3:01 pm

Re: Subform customization

Unread post 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
Error
Error.png (47.51 KiB) Viewed 6305 times
Whithout

Code: Select all

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

Greetings,
Timo
hanstel
Posts: 28
Joined: Sat Apr 30, 2016 2:51 am

Re: Subform customization

Unread post by hanstel »

use date() before call to you php code

nuSetHash('LogModDate',date());

// then call your php code

...
your-field = '#LogModDate#'
...
Ion2
Posts: 41
Joined: Mon Jan 18, 2016 3:01 pm

Re: Subform customization

Unread post 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
Post Reply