Hi @Harihara28692478zxj6 , If the AppleScript is complex you could save it as a text file from script editor (Script Editor saves Text formated files wth the .applescript extension) then load it into your Javascript and call app.doScript(). For example this applescript saved as text to my desktop:
tell application id "com.adobe.indesign"
activate
set d to active document
display dialog "Active Document: " & name of d
end tell
Called in this JS:
var as = readFile("~/Desktop/ASExample.applescript")
$.writeln(as)
/* returns
tell application id "com.adobe.indesign"
activate
set d to active document
display dialog "Active Document: " & name of d
end tell */
app.doScript(as, ScriptLanguage.applescriptLanguage);
/**
* Read a text file
* @ param p the path to the text file
* @ return the file‘s text
*/
function readFile(p) {
var f = new File(p);
f.open("r");
var x = f.read();
f.close();
return x; //returns the text in the file sampletext.txt
}
The result in InDesign:
