Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

Navigate to appropriate folder in TFM when globeadmin clicks on 'Upload Files' button Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Paul
Posts: 133
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 29 times
Been thanked: 3 times

Re: Navigate to appropriate folder in TFM when globeadmin clicks on 'Upload Files' button

Unread post by Paul »

Not sure I understand the best way to properly do that.
kev1n
nuBuilder Team
Posts: 4580
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 535 times
Contact:

Re: Navigate to appropriate folder in TFM when globeadmin clicks on 'Upload Files' button

Unread post by kev1n »

Paste the code into e.g. ChatGPT and ask it to fix your error
Paul
Posts: 133
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 29 times
Been thanked: 3 times

Re: Navigate to appropriate folder in TFM when globeadmin clicks on 'Upload Files' button

Unread post by Paul »

Wow! ChatGPT is WEIRD. It fixed the code and it worked!

Here is the ChatGPT version of the code:

Code: Select all

function nuVendorLogin(appId, table) {
	const tableName = table || nuSERVERRESPONSE.table;
	const params = new URLSearchParams({
		sessid: window.nuSESSION,
		appId: appId,
		table: tableName,
		timezone: nuSERVERRESPONSE.timezone
	});

	const url = `core/nuvendorlogin.php?${params.toString()}`;
	return window.open(url, appId); // use appId as window name for reuse
}

// 1. Open TFM via nuVendorLogin()
var win = nuVendorLogin('TFM');

// 2. Build the Tiny File Manager URL
var tab_id = nuSelectedTabId(); 
var tablabel = '';

if (tab_id === '68ca2d0c176d4d4') {
	tablabel = 'Audio';
} else if (tab_id === '68e16015b8742d6') {
	tablabel = 'Video';
} else if (tab_id === '68e16037843edff') {
	tablabel = 'Photo';
}

var recordNumber = nuRecordId();

// Construct the file path dynamically
var path = '/nubuilder2/third_party/tinyfilemanager/';

// Construct the full URL
var fileManagerUrl = `${path}tinyfilemanager.php?p=Case ${recordNumber}/Evidence/${tablabel}`;

// 3. Once the vendor login window is created, change its location
if (win) {
	setTimeout(() => {
		win.location.href = fileManagerUrl;
	}, 1000); // wait 1 second before redirecting
}
Paul
Posts: 133
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 29 times
Been thanked: 3 times

Re: Navigate to appropriate folder in TFM when globeadmin clicks on 'Upload Files' button

Unread post by Paul »

And it turns out that the 1 second delay IS needed. I tried removing it, logged out and logged back in and I got the Session Expired error.
Post Reply