Page 1 of 1

Redirect

Posted: Wed Mar 24, 2021 4:44 am
by ernesttan1976
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

Re: Redirect

Posted: Wed Mar 24, 2021 7:35 am
by kev1n
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.

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;
}

Re: Redirect

Posted: Thu Mar 25, 2021 8:04 am
by ernesttan1976
Thanks Kevin,

Success!