Skip to main content
Inspiring
January 21, 2024
Answered

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

  • January 21, 2024
  • 2 replies
  • 1147 views

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();
  }
This topic has been closed for replies.
Correct answer davidn5918184

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. 

2 replies

m1b
Community Expert
Community Expert
January 21, 2024

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

davidn5918184AuthorCorrect answer
Inspiring
January 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. 

Community Expert
January 21, 2024

Try defining the app at the start 

 

#target indesign

Inspiring
January 21, 2024

Unfortunately that doesn't work.