Subform customization

Re: Subform customization

Postby admin » Tue Feb 23, 2016 7:07 am

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
admin
Site Admin
 
Posts: 3235
Joined: Mon Jun 15, 2009 9:53 am

Re: Subform customization

Postby amarisJones » Wed Mar 09, 2016 6:32 pm

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.
Fashion bubble football : Bumper ball
amarisJones
 
Posts: 2
Joined: Wed Mar 09, 2016 12:30 pm

Re: Subform customization

Postby Ion2 » Wed Mar 09, 2016 8:10 pm

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/index.php/Forms#Save_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/index.php/Hash_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.com/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 11:31 pm

Re: Subform customization

Postby Ion2 » Wed May 25, 2016 10:01 pm

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
Ion2
 
Posts: 41
Joined: Mon Jan 18, 2016 11:31 pm

Re: Subform customization

Postby admin » Thu May 26, 2016 10:53 am

Timo,

I would use Now();

Steven
admin
Site Admin
 
Posts: 3235
Joined: Mon Jun 15, 2009 9:53 am

Re: Subform customization

Postby Ion2 » Thu May 26, 2016 4:15 pm

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
Ion2
 
Posts: 41
Joined: Mon Jan 18, 2016 11:31 pm

Re: Subform customization

Postby admin » Tue May 31, 2016 9:27 am

Timo,

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

Steven
admin
Site Admin
 
Posts: 3235
Joined: Mon Jun 15, 2009 9:53 am

Re: Subform customization

Postby Ion2 » Tue May 31, 2016 11:48 pm

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
Error
Error.png (47.51 KiB) Viewed 3460 times

Whithout

Code: Select all
    SET inventory_log_modified_at = NOW();

the code is working.

Greetings,
Timo
Ion2
 
Posts: 41
Joined: Mon Jan 18, 2016 11:31 pm

Re: Subform customization

Postby hanstel » Tue May 31, 2016 11:59 pm

use date() before call to you php code

nuSetHash('LogModDate',date());

// then call your php code

...
your-field = '#LogModDate#'
...
hanstel
 
Posts: 28
Joined: Sat Apr 30, 2016 10:21 am

Re: Subform customization

Postby Ion2 » Thu Jun 16, 2016 12:55 am

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
Ion2
 
Posts: 41
Joined: Mon Jan 18, 2016 11:31 pm

PreviousNext

Return to General