PHP code in subform

Questions related to using nuBuilder Forte.

PHP code in subform

Unread postby sputs » Thu Jun 03, 2021 1:12 am

Hi,

I have added some simple After Submit code in a subform. It runs well if I execute the code on the subform directly, but when it is run as a subform nothing happens.
The error message at the end of the code also does not show up when run as a subform.

Am I missing something?

AS Code in the subform is simply:

Code: Select all
#Update the user
if ('#USER_ID#' != '') {
  $s = "UPDATE table SET updated_uid='#USER_ID#' WHERE disease='#disease#' ";
  $t  = nuRunQuery($s);
  nuDisplayError($s);
}
Last edited by kev1n on Thu Jun 03, 2021 1:43 am, edited 1 time in total.
Reason: Added Code tags
sputs
 
Posts: 9
Joined: Mon Feb 08, 2021 4:37 am

Re: PHP code in subform

Unread postby kev1n » Thu Jun 03, 2021 1:17 am

Hi,

In think you'll have to add that code in the main form's AS event.
kev1n
nuBuilder Team
 
Posts: 1763
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: PHP code in subform

Unread postby sputs » Thu Jun 03, 2021 1:28 am

Ok...Then how do I keep track of who updates what, if a new record is inserted in a subform?
sputs
 
Posts: 9
Joined: Mon Feb 08, 2021 4:37 am

Re: PHP code in subform

Unread postby kev1n » Thu Jun 03, 2021 1:43 am

sputs wrote: who updates what


Can you describe in more detail what information/data has to be stored and where?
kev1n
nuBuilder Team
 
Posts: 1763
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: PHP code in subform

Unread postby sputs » Thu Jun 03, 2021 1:53 am

I have this form with subforms:

Screenshot from 2021-06-02 18-11-30.png
Screenshot from 2021-06-02 18-11-30.png (83.28 KiB) Viewed 69 times



I would like to store the #USER_ID# with the record if a user enters a new record in a subform.

Like for symptoms, I have this table where the #USER_ID# needs to be updated on each insert:
Screenshot from 2021-06-02 18-15-10.png
Screenshot from 2021-06-02 18-15-10.png (25.58 KiB) Viewed 69 times


Hope I explained it clear enough. Essentially I need to track which user inserts records (in subforms).
sputs
 
Posts: 9
Joined: Mon Feb 08, 2021 4:37 am

Re: PHP code in subform

Unread postby kev1n » Thu Jun 03, 2021 1:56 am

kev1n
nuBuilder Team
 
Posts: 1763
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: PHP code in subform

Unread postby sputs » Thu Jun 03, 2021 2:07 am

Brilliant!!! Thank you so much!
sputs
 
Posts: 9
Joined: Mon Feb 08, 2021 4:37 am


Return to General

Who is online

Users browsing this forum: No registered users and 15 guests