Can't access variables of edit form in after save

Questions related to customising nuBuilder Forte with Javascript or PHP.

Can't access variables of edit form in after save

Postby mabe » Tue May 28, 2019 10:46 pm

Hi there!

I have build a browse edit form.
After a user saves data, I want to execute a sql query which contains the values, that the user just entered.
However, I only get empty values using PHP:

Trying to execute this:
Code: Select all
$s = "insert into dashboard (id, project_name ) VALUES (" . nuLookupRecord()->id . ", '" . nuLookupRecord()->project_name . "');";
nuRunQuery($s);


...resolves with the following error:
[0] :
===USER==========

globeadmin

===PDO MESSAGE===

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' '')' at line 1

===SQL===========

insert into dashboard (id, project_name ) VALUES (, '');

===BACK TRACE====

/var/www/html/nubuilder/nucommon.php(1254) : eval()'d code - line 2 (nuRunQuery)

/var/www/html/nubuilder/nucommon.php - line 1254 (eval)

/var/www/html/nubuilder/nudata.php - line 365 (nuEval)

/var/www/html/nubuilder/nuapi.php - line 52 (nuUpdateDatabase)


Does somebody know, what I am doing wrong?
Thank you very much!

Cheers,

Malte
mabe
 
Posts: 4
Joined: Tue May 28, 2019 10:33 pm

Re: Can't access variables of edit form in after save

Postby kev1n » Tue May 28, 2019 11:06 pm

Hi,

nuLookupRecord() can only be used to return fields from a selected Lookup record.

Use Hash Cookies in PHP AS (After Save):
https://wiki.nubuilder.net/nubuilderfor ... sh_Cookies

e.g. #RECORD_ID# and #project_name#
kev1n
 
Posts: 190
Joined: Mon Oct 15, 2018 2:13 am

Re: Can't access variables of edit form in after save

Postby mabe » Wed Jun 05, 2019 5:20 pm

kev1n wrote:Hi,

nuLookupRecord() can only be used to return fields from a selected Lookup record.

Use Hash Cookies in PHP AS (After Save):
https://wiki.nubuilder.net/nubuilderfor ... sh_Cookies

e.g. #RECORD_ID# and #project_name#


Thank you very much, now it's working perfectly! :)
mabe
 
Posts: 4
Joined: Tue May 28, 2019 10:33 pm


Return to Custom Code