Welcome to the nuBuilder Forums!

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

Unable to understand Procedures in nuBuilder

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
mjd300
Posts: 21
Joined: Sat Oct 15, 2022 8:47 am
Has thanked: 1 time
Been thanked: 2 times

Unable to understand Procedures in nuBuilder

Unread post by mjd300 »

Not sure if this is the right section, or if it should be General (feel free to move).

I cannot figure out how Procedures work in nuBuilder.

I have tried the following:
  • a Run object that calls a procedure
  • a button (Input) that has an onclick using nuRunPHPHidden('ProcedureName', 1)
I initially tried a curl call and an echo, which came back as an uncaught error (though in the error was the correct returned data). For clarify, the Curl call works when run directly.

So now I am experimenting by just echoing a string.

It always comes back with an uncaught error (as shown in image).

I understand that maybe you cannot echo / print results, but I do not see any procedure to deal display of returned data. It seems unlikely we could use javascript there to update an element directly.

I also tried nuSetFormValue on a Word field that is in the same form, but nothing happened (no error). It seems that is not for this use-case

What am I (and the documentation) missing here?

Thanks.
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4298
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Unable to understand Procedures in nuBuilder

Unread post by kev1n »

If you use echo() or var_dump() in the Procedure, use nuRunPHP.

Or use nuJavascriptCallback when you run a Procedure with nuRunPHPHidden() to pass data from PHP to JS.

nuSetFormValue() can only be used in a Lookup's After Browse event.
mjd300
Posts: 21
Joined: Sat Oct 15, 2022 8:47 am
Has thanked: 1 time
Been thanked: 2 times

Re: Unable to understand Procedures in nuBuilder

Unread post by mjd300 »

Ok, thanks. I'll try that with newRunPHP.

I did manage to update a Word field, with this, so that is a good starting point as well.

$js = " document.getElementById('word_result').innerHTML = 'It worked!'; ";
nuJavascriptCallback($js);
mjd300
Posts: 21
Joined: Sat Oct 15, 2022 8:47 am
Has thanked: 1 time
Been thanked: 2 times

Re: Unable to understand Procedures in nuBuilder

Unread post by mjd300 »

To check (and for anyone else who wants to do this), this worked to pass a PHP variable to JS, but not sure it is the best way (or nuBuilder way):

$js = " document.getElementById('word_result').innerHTML = " . "\"" . $var . "\"" . "; ";

It seemed to only work when I had the quotes around the variable, when the $js is used in nuJavascriptCallback($js).
kev1n
nuBuilder Team
Posts: 4298
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Unable to understand Procedures in nuBuilder

Unread post by kev1n »

This should do the job too:

Code: Select all

$js = " nuSetText('word_result','$var'); ";
mjd300
Posts: 21
Joined: Sat Oct 15, 2022 8:47 am
Has thanked: 1 time
Been thanked: 2 times

Re: Unable to understand Procedures in nuBuilder

Unread post by mjd300 »

Thanks. Yes, that's much neater
Post Reply