This topic is locked
[SOLVED]

 Update multiple records and fields on the List page

7/17/2019 7:36:14 AM
PHPRunner General questions
R
ruud author

The next code works fine:

global $dal;
while ( $data = $button->getNextSelectedRecord() ) {

// set ReportsTo field to 'Bob Smith'

$sql = "Update employees set ReportsTo='Bob Smith' where KeyField=".$data["KeyField"];

CustomQuery($sql);

}

$result["txt"] = "Records were updated.";
BUT, I want to update two fields more. A date field with Now() and a field called FinalExportBy (filled with the user who is logged in.
Anybody can help. How can I fill three fields?
Thanks
Ruud

admin 7/17/2019

Yes, read this article for instance:

https://www.geeksforgeeks.org/sql-update-statement/
Google search phrase: sql update statement

R
ruud author 7/17/2019



Yes, read this article for instance:

https://www.geeksforgeeks.org/sql-update-statement/
Google search phrase: sql update statement


Hi Sergey. Thanks
It works almost. I want for the FinalExportBy the logged in user. How do I state that??
global $dal;
while ( $data = $button->getNextSelectedRecord() ) {

// set ReportsTo field to 'Bob Smith'

$sql = "Update VoucherLines SET FinalExportYN='1',DateFinalExport=CURDATE(),FinalExportBy='1' where VoucherLinesID=".$data["VoucherLinesID"];
CustomQuery($sql);

}
$result["txt"] = "Records were updated.";

R
ruud author 7/17/2019

global $dal;
while ( $data = $button->getNextSelectedRecord() ) {

// set ReportsTo field to 'Bob Smith'

$sql = "Update VoucherLines SET FinalExportYN='1',DateFinalExport=CURDATE(),FinalExportBy='getUserName()' where VoucherLinesID=".$data["VoucherLinesID"];
CustomQuery($sql);

}
$result["txt"] = "Records were updated.";
It is about FinalExportBy: I also tried Security:: getUserName and lots of other possibilities. No success.
How do I get the username in the field FinalExportBy?