Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

PHP code in subform

Questions related to using nuBuilder Forte.
Post Reply
sputs
Posts: 27
Joined: Sun Feb 07, 2021 8:07 pm

PHP code in subform

Unread post 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);
}
Last edited by kev1n on Wed Jun 02, 2021 6:13 pm, edited 1 time in total.
Reason: Added Code tags
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: PHP code in subform

Unread post by kev1n »

Hi,

In think you'll have to add that code in the main form's AS event.
sputs
Posts: 27
Joined: Sun Feb 07, 2021 8:07 pm

Re: PHP code in subform

Unread post by sputs »

Ok...Then how do I keep track of who updates what, if a new record is inserted in a subform?
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: PHP code in subform

Unread post by kev1n »

sputs wrote: who updates what
Can you describe in more detail what information/data has to be stored and where?
sputs
Posts: 27
Joined: Sun Feb 07, 2021 8:07 pm

Re: PHP code in subform

Unread post 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).
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: PHP code in subform

Unread post by kev1n »

sputs
Posts: 27
Joined: Sun Feb 07, 2021 8:07 pm

Re: PHP code in subform

Unread post by sputs »

Brilliant!!! Thank you so much!
Post Reply