Skip to main content
Inspiring
March 8, 2019
Answered

How to run synchronous js in jsx?

  • March 8, 2019
  • 1 reply
  • 1350 views

I'm trying to run a promise in jsx.  My current setup is cep to jsx and code executes but I'm trying to add a promise so my code can be synchronous.

Here is a simple example:

      var f = new File("/Users/ohms/Desktop/cltemplate.ai");

      function setTemplate(f) {

        return new Promise((resolve, reject) => {

          var doc = app.open (f);

          return resolve();

        }

        );

      }

      // open the template

      setTemplate(f);

This is giving me an error when I run it in extended script toolkit.

Any ideas how I can do this?

This topic has been closed for replies.
Correct answer Ten A

ExtendScript basically works synchronously.

Here is an example.

var f = new File("/Users/ohms/Desktop/cltemplate.ai");

if (f.exists) app.open(f);

else alert("File not found...");

And you'd better read first scripting guide in below.

Adobe I/O Console

1 reply

Ten A
Community Expert
Community Expert
March 11, 2019

ExtendScript as EC3 and it doesn't support promise.

OhmsGAuthor
Inspiring
March 12, 2019

Ok thank you.  How can I run code synchronous?

Currently I read default would be synchronous but it doesn't seem to be the case.

Ten A
Community Expert
Ten ACommunity ExpertCorrect answer
Community Expert
March 13, 2019

ExtendScript basically works synchronously.

Here is an example.

var f = new File("/Users/ohms/Desktop/cltemplate.ai");

if (f.exists) app.open(f);

else alert("File not found...");

And you'd better read first scripting guide in below.

Adobe I/O Console