• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
8

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

Community Beginner ,
Jun 14, 2023 Jun 14, 2023

Copy link to clipboard

Copied

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

TOPICS
Scripting , UXP Scripting

Views

115

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2023 Jun 29, 2023

Copy link to clipboard

Copied

LATEST

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

Mike Witherell

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines