Page 1 of 1

Update Current record

Posted: Thu May 17, 2018 12:02 pm
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 ...

Re: Update Current record

Posted: Thu May 17, 2018 12:44 pm
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);

Re: Update Current record

Posted: Sat May 19, 2018 1:15 am
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