Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Redirect

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
ernesttan1976
Posts: 51
Joined: Sat May 16, 2020 10:08 am

Redirect

Unread post 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
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4299
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Redirect

Unread post 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;
}
ernesttan1976
Posts: 51
Joined: Sat May 16, 2020 10:08 am

Re: Redirect

Unread post by ernesttan1976 »

Thanks Kevin,

Success!
Post Reply