Skip to main content
Participating Frequently
June 14, 2023
Question

Script using uxp module crashes in Developer Tool, but not without

  • June 14, 2023
  • 1 reply
  • 294 views

The following script runs fine when launched from the Scripts Panel, but when run in the UXP Developer Tool, it gives this error message: "Cannot read properties of undefined (reading 'on')".

 

const versionInfo = await getVersion();
alert(versionInfo);

function alert(msg) {
    const theDialog = app.dialogs.add(),
        col = theDialog.dialogColumns.add();
	
	msg.split('\n').forEach(line => {
		const colText = col.staticTexts.add();
		colText.staticLabel = line;
	});
    
	theDialog.canCancel = false;
    theDialog.show();
    theDialog.destroy();
}

async function getVersion() {
	const versions = require('uxp').versions;
    const host = require('uxp').host;
    return `Host: ${host.name} ${host.version} ${host.uiLocale}\nUXP: ${versions.uxp}`;
}

Stepping through, require('uxp').host is the offending command.

Using InDesign 18.3 with UXP 6.5.0

This topic has been closed for replies.

1 reply

Mike Witherell
Community Expert
Community Expert
June 29, 2023

My experiments with UXP indicate that it is an unfinished product feature and cannot be relied upon yet.

Mike Witherell