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.

Update Current record

Questions related to using nuBuilder Forte.
Post Reply
191brian
Posts: 6
Joined: Wed Mar 14, 2018 10:39 am
Location: UK
Contact:

Update Current record

Unread post by 191brian »

Hi All

I have created a form that lists open jobs with limited info, I would like to add a button that will runs a procedure to update the current job record with the the currently logged in user id then opens another form showing the mor of the job details.

I am ok with creating the button but need some help with the procedure, how do I refer the current record and current user? is there some sample code I could take a look at?

Thanks
Brian ...
You do not have the required permissions to view the files attached to this post.
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Update Current record

Unread post by toms »

Hi Brian,

Add a procedure (Builders -> Procedure) that looks like this:
phpprocedure.png

Code: Select all

$sql = "UPDATE table_name SET user_id = ? WHERE table_name_id = '#record_id#' ";

nuRunQuery($sql, [getnuUserName()]);

function getnuUserName() {
    $nuUserObj = nuUser();
    if ($nuUserObj == "")
    {
      $nuUserName = "globeadmin";
    } else
    {
      $nuUserName = $nuUserObj->sus_name;
    }
    return $nuUserName;
} 


$j = " 
// open a form, add your parameters here:
 nuForm(....); // https://wiki.nubuilder.cloud/index.php/Javascript#nuForm

";

nuJavascriptCallback($j);

Then, when your button is clicked, run this code to execute the PHP procedure:

Code: Select all

 nuRunPHPHidden("updateuser", 1);
You do not have the required permissions to view the files attached to this post.
admin
Site Admin
Posts: 2829
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 30 times

Re: Update Current record

Unread post by admin »

Brian,

As toms showed, you can use Hash Cookies.

https://wiki.nubuilder.cloud/ ... sh_Cookies

You can use nuHash(), inside nuDebug() to find what Hash Cookies are available.

https://wiki.nubuilder.cloud/ ... PHP#nuHash

https://wiki.nubuilder.cloud/ ... HP#nuDebug


Steven
Post Reply