Hi,
I have a browse form which uses this custom SQL.
When I click one entry I want it to redirect to "Employees" form with the emplyee_id.
However the employee id does not link correctly.
SELECT
certificate.certificate_expiry,
DATEDIFF(certificate_expiry,curdate()),
cert_type.cert_name,
employee.emp_name,
certificate.certificate_type_id,
FROM
certificate
JOIN cert_type ON cert_type.cert_type_id = certificate.certificate_type_id
JOIN employee ON employee.employee_id = certificate.employee_id
WHERE NOT certificate_expiry = DATE('0000-00-00') AND employee.emp_active = 1 AND DATEDIFF(certificate_expiry,curdate()) < 61
ORDER BY DATEDIFF(certificate_expiry,curdate()) ASC
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Redirect
-
- Posts: 51
- Joined: Sat May 16, 2020 10:08 am
-
- nuBuilder Team
- Posts: 4299
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Redirect
A redirection only works if the Primary Keys of both tables are the same.
You'll need to add the employee_id column (as hidden column) to your Browse Table and then use this JS under Custom Code.
You'll need to add the employee_id column (as hidden column) to your Browse Table and then use this JS under Custom Code.
Code: Select all
function nuSelectBrowse(e){
var row = $('#' + e.target.id).attr('data-nu-row');
var empId = $('#nucell_' + row + "_" + "0").html(); // Replace 0 with the column index, 0 = 1st column, 1 = 2nd column etc.
nuForm('insert_employee_form_id_here'), empId, '', '', '0');
return false;
}