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.
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
Re: Navigate to appropriate folder in TFM when globeadmin clicks on 'Upload Files' button
Not sure I understand the best way to properly do that.
-
- nuBuilder Team
- Posts: 4579
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 534 times
- Contact:
Re: Navigate to appropriate folder in TFM when globeadmin clicks on 'Upload Files' button
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
Wow! ChatGPT is WEIRD. It fixed the code and it worked!
Here is the ChatGPT version of the code:
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
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.