Skip to main content
New Participant
June 10, 2022
Answered

Dataviews scripting error

  • June 10, 2022
  • 3 replies
  • 468 views

Hello,

I am taking my first steps in scripting in InDesign and I am faced with a simple issue. I am trying to execute this script from the Scripts Panel in InDesign CC 2021:

var easyCatalogFilePath = "testFile.txt"

var myEasyCatalog = app.easycatalogObject;
var myDS = app.easycatalogObject.datasources.item(easyCatalogFilePath );
var myDV = myDS.dataviews.add();
 
However, when I run this I get an error on line myDS.dataviews.add() that Object is Invalid. This should be a simple EasyCatalog script to open a data source. Has anyone faced a similar issue?
This topic has been closed for replies.
Correct answer Kasyan Servetsky

Very interesting! I didn't know that EasyCatalog is scriptable. Do they have some sample scripts? Found them here. I don't have it installed but your very first line makes me embarrassed. From the variable name, I assume, it should be a full path to the file, not the file name. Something like this:

 

 

var easyCatalogFilePath = "/C/folder/subFolder/subSubFolder/testFile.txt";

 

 

 

Make sure to check if the file exists and if so go on with your code.

 

 

if (File(easyCatalogFilePath).exists) {
   // do something
}

 

 

 

3 replies

Kasyan Servetsky
Kasyan ServetskyCorrect answer
Braniac
June 10, 2022

Very interesting! I didn't know that EasyCatalog is scriptable. Do they have some sample scripts? Found them here. I don't have it installed but your very first line makes me embarrassed. From the variable name, I assume, it should be a full path to the file, not the file name. Something like this:

 

 

var easyCatalogFilePath = "/C/folder/subFolder/subSubFolder/testFile.txt";

 

 

 

Make sure to check if the file exists and if so go on with your code.

 

 

if (File(easyCatalogFilePath).exists) {
   // do something
}

 

 

 

Bill3862Author
New Participant
June 10, 2022

I think it's time to call it a day when you forget to paste the whole path and pay no mind to it! Thank you for pointing that out Kasyan.

brian_p_dts
Braniac
June 10, 2022

Don't know much about Easy Catalog scripting but I would start by ensuring you have the full path to your txt file. Ie, "~/Desktop/testFile.txt" would point to your desktop, whereas app.activeScript.fsName + "/testFile.txt" would point to the same directory as wherever you are executing the script from. 

rob day
Braniac
June 10, 2022

Hi @Bill3862 var myEasyCatalog = app.easycatalogObject; would also throw an error because there‘s no easycatalogObject Application object.

 

Here’s the InDesign ExtendScript API:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Application.html

brian_p_dts
Braniac
June 10, 2022

Rob, I believe Easy Catalog can be scripted: https://www.65bit.com/software/easycatalog/modules/scripting-module/