This issue is usually caused by incompatible widgets or outdated Data Widgets after upgrading to Mendix 11. In Mendix 11 some client APIs changed, and older widgets may incorrectly handle the result of getDocumentUrl(), which can lead to [object Promise] being concatenated into the URL.
First, make sure that all Marketplace modules and widgets (especially Data Widgets and file-related widgets) are updated to versions compatible with Mendix 11. After upgrading them, delete the deployment folder and run the application again so the client bundles are regenerated.
If the problem started immediately after the upgrade, it is very likely related to a widget compatibility issue rather than System.FileDocument itself.
If this resolves the issue, please close the topic.
Hi Samuel Évora
In Mendix 11, the client runtime moved several APIs to async operations to support the new React-based client and microfrontend architecture Normally Mendix resolves this internally, but older page bundles or widgets compiled with Mendix 10 may still treat it as a synchronous value, which results in the Promise object being concatenated into a string.
You can use the below code:
import { getFileUrl } from "mx-api/data";
async function downloadFile(e) {
const obj = e.mxobject;
const isRemote = obj.metaData.isRemoteFileEntity;
if (!obj.get("HasContents") && !isRemote) return;
// Prefer the new API in Mx 11
const url = await getFileUrl({
object: obj,
// Optional: keep server name if you want to control the download name
fileName: isRemote ? undefined : encodeURIComponent(obj.get("Name")),
// thumbnail: false // default
});
window.open(`${url}&target=window`, "mendix_file");
}
basically you have to get the getfileurl from import[Mendix 11 Client API Documentation mx-api/data] or else try the below code
// Put this at the top of your JS action file (or inside BEGIN EXTRA CODE)
import { getFileUrl } from "mx-api/data"; // Mx 11 client API
// If this is inside a generated JS action, ensure "import 'mx-global';" is present at file top.
async function downloadFile(e) {
const obj = e.mxobject;
const isRemote = obj?.metaData?.isRemoteFileEntity;
// Respect HasContents for local files; remote files may not have HasContents set
if (!obj.get("HasContents") && !isRemote) return;
// Optional: preserve the server-side download name (Mx will set the Content-Disposition)
// Avoid double-encoding: pass the raw name; Mendix handles header encoding.
const fileName = isRemote ? undefined : obj.get("Name");
// Mendix 11: getFileUrl is async and returns Promise<string>
const url = await getFileUrl({
object: obj,
fileName, // optional; omit for remote entities
// thumbnail: false // default
});
window.open(`${url}&target=window`, "mendix_file");
}
Will work. If not let me know I can help you.