Page 1 of 1

SQL Queries in Breadcrumb Titles

Posted: Fri May 17, 2024 11:35 am
by ajackson
Although I can use Hash cookies in Breadcrumb titles, it seems that I'm unable to use them in SQL statements in Breadcrumb titles.
Is there a way round this?

Cheers,
Alan
Lov'in nuBuilder, keep up the good work! :D

Re: SQL Queries in Breadcrumb Titles

Posted: Fri May 17, 2024 12:03 pm
by kev1n
Hi Alan,

Could you share your SQL statement?

Re: SQL Queries in Breadcrumb Titles

Posted: Fri May 17, 2024 12:19 pm
by ajackson
The SQL statement I'm using goes like this:

select extpatientid from Patient_v where patientid = '#PatientID#'

but this cases a fatal error.

However, if I wrap the statement in another select it does not crash and I can see on the server that the hash cookie #PatientID# is not being interpreted.

select (select extpatientid from Patient_v where patientid = '#PatientID#')

Furthermore, if I just use #PatientID# in the Breadcrumb title it is successfully parsed.

Hope this helps,
Alan

Re: SQL Queries in Breadcrumb Titles

Posted: Fri May 17, 2024 12:40 pm
by kev1n
In my case it also happens that the Hash Cookies don't resolve in SQL. I will investigate this further.
As a workaround, you can use the JS function nuSetTitle() to set the breadcrumb title.
Please note that extpatientid must be an object on your form (can be hidden).
Alternatively. use a display object where you can use SQL and then set the title with nuSetTitle().

Re: SQL Queries in Breadcrumb Titles

Posted: Fri May 17, 2024 12:49 pm
by kev1n
I believe this should fix it:
In nuform.php, replace the function nuBreadcrumbDescriptionPart() with this one:

Code: Select all

function nuBreadcrumbDescriptionPart($bt){

	$bt = nuReplaceHashVariables($bt);
	if(strtolower(substr(nuTrim($bt), 0, 6)) == 'select'){
		$t	= nuRunQuery($bt);
		return db_num_rows($t)> 0 ? db_fetch_row($t)[0] : '';
	}

	return $bt;

}

Re: SQL Queries in Breadcrumb Titles

Posted: Fri May 17, 2024 1:20 pm
by ajackson
Wow, you are a champion!
Will this fix be in future releases?

I'm currently testing nuBuilder out on legacy databases to see how it can work with existing composite natural keys.
Looking good so far...if this can be achieved then I think you're on to a winner. Goodbye Access!

Cheers,
Alan

Re: SQL Queries in Breadcrumb Titles

Posted: Fri May 17, 2024 5:11 pm
by kev1n
Fix is on Github, thanks for testing!