Before Edit custom code does not run
Posted: Wed Apr 23, 2025 9:13 am
Hello,
I created a launch form and added some Php code to the Before Edit section. The Php code fetches data from database and saves the result in a JavaScript variable. The JavaScript variable is used to display a Google Chart. The Following code is used in Before Edit section:
The launch form works fine for globeadmin user but for other users it only shows the Google Chart if the refresh menu button is pressed. I checked the developers console and it showed that nuapi.php does not have the JavaScript variable when the page is initially loaded for non admin users. When the refresh button is pressed the nuapi.php contains the JavaScript variable and the chart shows.
Thanks,
Nadir Latif
I created a launch form and added some Php code to the Before Edit section. The Php code fetches data from database and saves the result in a JavaScript variable. The JavaScript variable is used to display a Google Chart. The Following code is used in Before Edit section:
Code: Select all
$select = "SELECT count(*) as total, workmen.tbl_workmen_name FROM tasks, workmen WHERE tasks.workman_id = workmen.workmen_id GROUP BY workmen.workmen_id;";
$stmt = nuRunQuery($select);
$data = "window.googleChartsData = [['Worker', 'Task Count'],";
while($row = db_fetch_object($stmt)) {
$data .= "['". $row->tbl_workmen_name . "', " . $row->total . "],";
}
$data .= "];";
nuAddJavaScript($data);
Thanks,
Nadir Latif