Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

nuRunPHPHiddenWithParams

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
nuno
Posts: 2
Joined: Tue Jan 04, 2022 1:44 am
Has thanked: 1 time

nuRunPHPHiddenWithParams

Unread post by nuno »

Hello, I´m new to nubuilder and i'm asking some guidance in this subject:

I'm trying to run a procedure with "nuRunPHPHiddenWithParams": Starting the procedure seems to work fine since the "#param#" is created and displayed in the form info table:

param "BxZwYXJhbTEWAxYxMjM0NTYWAhZwYXJhbTIWAxYyMzE2NTQ1NDQ1NjQWBw=="

inside the php code the base64_decode("#param#") also seems to work fine since:

$param=base64_decode('#param#');

nuDebug($param);

returns [0] : param1123456param2231654544564

what doesn't work is the $param=json_decode($param,false) since i'm unable to retrieve anything from the object with:

§par1=$param->param1

and also $param=json_decode(base64_decode('#param#'); apparently doesn't create the object.

I separated the "base64_decode" and "json_decode" functions for debugging purposes only.

Any sort of comment or suggestion would be very appreciated.
kev1n
nuBuilder Team
Posts: 4562
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 528 times
Contact:

Re: nuRunPHPHiddenWithParams

Unread post by kev1n »

Hi,

nuBase64encode() is somehow flawed. Try replacing nuRunPHPHiddenWithParams() with

Code: Select all

function nuRunPHPHiddenWithParams(i, paramName, paramValue, rbs) {
	nuSetProperty(paramName, btoa(JSON.stringify(paramValue)));
	nuRunPHPHidden(i, rbs);
}
My test:

JS:

Code: Select all

nuRunPHPHiddenWithParams('test_procedure', 'param', {param1: '12345'}, 0); 
PHP:

Code: Select all

$param = json_decode(base64_decode('#param#')); // retrieve the parameters
$param1  = $param->param1;

nuDebug($param1); // returns 12345
nuno
Posts: 2
Joined: Tue Jan 04, 2022 1:44 am
Has thanked: 1 time

Re: nuRunPHPHiddenWithParams

Unread post by nuno »

Thanks for the help. worked like a charm.
Post Reply