Page 2 of 2

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

Posted: Mon Oct 06, 2025 7:31 am
by Paul
Not sure I understand the best way to properly do that.

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

Posted: Mon Oct 06, 2025 7:49 am
by kev1n
Paste the code into e.g. ChatGPT and ask it to fix your error

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

Posted: Mon Oct 06, 2025 8:08 am
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
}

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

Posted: Mon Oct 06, 2025 8:12 am
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.