This topic is locked

Custom Button update current user field value and more.

7/7/2023 8:58:37 PM
PHPRunner General questions
L
lineamovil author

Hello!
I created a CUSTOM BUTTON, and this button should update 3 fields in the record.
1.- Update the username $_SESSION["UserName"]
2. Should place the Timestamp when the button was pressed.
3. Should also update a field with the value of "Finished"
Does anyone share the solution. I was looking the help file, but it wont let me update. Thank you for your help.

L
lineamovil author 7/7/2023

Made this, but didnt work
Client
params ["Usuario"] = $_SESSION["UserName"]; Server
`global $conn;

$record = $button->getCurrentRecord();

$strSQLUpdate = "UPDATE rutassub SET Usuario =".$_SESSION["UserName"]." where foliodetalle = ".$record["FolioDetalle"]."";

db_exec($strSQLUpdate,$conn);`

Sergey Kornilov admin 7/8/2023

First of all, you cannot use session variables in Javascript events like ClientBefore. Most likely this errors prevents other parts of the code from workinng.
Besides that, make sure you consult the following troubleshooting quide:
https://xlinesoft.com/phprunner/docs/troubleshooting_custom_buttons.htm

L
lineamovil author 7/12/2023

Thank you!
it worked
`$userData = Security::getUserName();
$userDataX = now();
global $conn;

$record = $button->getCurrentRecord();

$strSQLUpdate = "UPDATE rutassub SET usuario ='".$userData."', registro='".$userDataX."', Lng='".$userDataLong."', Lat='".$userDataLat."' , Realizado='Si' where foliodetalle = ".$record["FolioDetalle"]."";

db_exec($strSQLUpdate,$conn);`