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

.idjs script, UXPScript Error! Error String: app is not defined

Engaged ,
Jan 21, 2024 Jan 21, 2024

Copy link to clipboard

Copied

I'm trying to learn to use .idjs and I keep runing into the error: UXPScript Error! Error String: app is not defined. It's a very simple script to test and I think it should work but it doesn't. Anyone have any guidence. 

let myInDesign = require("indesign");
let myDoc = myInDesign.app.activeDocument;
let myLayer = myDoc.layers.item("Layer 1");

  if (!myDoc.layers.itemByName("DIGITAL").isValid) {
    myDoc.layers.add({ name: "DIGITAL" });
  }

  if (myDoc.layers.itemByName("Layer 1").isValid) {
  myLayer.remove();
  }
TOPICS
Scripting

Views

560

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

correct answers 1 Correct answer

Engaged , Jan 21, 2024 Jan 21, 2024

Ok, well this is embarrassing. I had duplicated the the script to work on it from vscode and instead of working on the one in inDesign I added it to vscode. Doh!  So I did get it to work now if I could just get it to work from the uxp plugin. Thanks for the help all. 

Votes

Translate

Translate
Community Expert ,
Jan 21, 2024 Jan 21, 2024

Copy link to clipboard

Copied

Try defining the app at the start 

 

#target indesign

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
Engaged ,
Jan 21, 2024 Jan 21, 2024

Copy link to clipboard

Copied

Unfortunately that doesn't work.

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
Community Expert ,
Jan 21, 2024 Jan 21, 2024

Copy link to clipboard

Copied

Hi @davidn5918184, I just ran your code on ID 19.1, MacOS 14.2.1, and it worked as expected (created a layer and removed the other). I executed the script via the script panel. Can you give more info on your set up? Are you running via the script panel?

- Mark

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
Engaged ,
Jan 21, 2024 Jan 21, 2024

Copy link to clipboard

Copied

LATEST

Ok, well this is embarrassing. I had duplicated the the script to work on it from vscode and instead of working on the one in inDesign I added it to vscode. Doh!  So I did get it to work now if I could just get it to work from the uxp plugin. Thanks for the help all. 

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