Page 1 of 1

PHP code in subform

Posted: Wed Jun 02, 2021 5:42 pm
by sputs
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);
}

Re: PHP code in subform

Posted: Wed Jun 02, 2021 5:47 pm
by kev1n
Hi,

In think you'll have to add that code in the main form's AS event.

Re: PHP code in subform

Posted: Wed Jun 02, 2021 5:58 pm
by sputs
Ok...Then how do I keep track of who updates what, if a new record is inserted in a subform?

Re: PHP code in subform

Posted: Wed Jun 02, 2021 6:13 pm
by kev1n
sputs wrote: who updates what
Can you describe in more detail what information/data has to be stored and where?

Re: PHP code in subform

Posted: Wed Jun 02, 2021 6:23 pm
by sputs
I have this form with subforms:
Screenshot from 2021-06-02 18-11-30.png

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
Hope I explained it clear enough. Essentially I need to track which user inserts records (in subforms).

Re: PHP code in subform

Posted: Wed Jun 02, 2021 6:26 pm
by kev1n

Re: PHP code in subform

Posted: Wed Jun 02, 2021 6:37 pm
by sputs
Brilliant!!! Thank you so much!