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

How do I call ExtendScript functions from Javascript

Explorer ,
Apr 09, 2022 Apr 09, 2022

Copy link to clipboard

Copied

Hello!

I am struggling to connect JS and Extendscript. To start, my folder path is workspace/client/index.js and workspace/host/index.jsx.

My JS code is:

Screen Shot 2022-04-09 at 8.00.07 PM.png

and my JSX code is:

Screen Shot 2022-04-09 at 8.00.30 PM.png

I want to return the path, start, and end times from Extendscript, but I'm not getting any return value from JS. What am I doing wrong? Thank you!

TOPICS
How to , SDK

Views

321

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
Explorer ,
Apr 09, 2022 Apr 09, 2022

Copy link to clipboard

Copied

"I'm not getting any return value from JS" - I meant JSX

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
Explorer ,
Apr 12, 2022 Apr 12, 2022

Copy link to clipboard

Copied

Also, I just realized that I'm missing a bracket, but after fixing that it still did not print the return value. I added a simple console.log("hi"); before the evalScript and that printed out though.

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
Explorer ,
Apr 17, 2022 Apr 17, 2022

Copy link to clipboard

Copied

Update: I removed the brackets from getInfo() in  ' csInterface.evalScript("getInfo()", function(array_string) ' and it printed the whole entire function as a string. Not what I intended, but at least that's something. What went awry? 

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
Explorer ,
Apr 17, 2022 Apr 17, 2022

Copy link to clipboard

Copied

Screen Shot 2022-04-17 at 11.39.35 PM.png

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
Explorer ,
Apr 19, 2022 Apr 19, 2022

Copy link to clipboard

Copied

I just realized that getInfo returns a string of the function which is why it works. 

my jsx looks like this now:

Screen Shot 2022-04-19 at 12.13.48 PM.png

and my js looks like this:

Screen Shot 2022-04-19 at 12.14.48 PM.png

However, I'm getting an EvalScript Error and I don't know why.

Screen Shot 2022-04-19 at 12.15.23 PM.png

Can somebody help? Thank you!

 

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
Adobe Employee ,
Apr 19, 2022 Apr 19, 2022

Copy link to clipboard

Copied

PProPanel offers multiple examples of getting data across the ExtendScript <--> JavaScript boundary. 


Also, when calling evalScript() within JavaScript, you'll need to include the outermost layer of ExtendScript defintion, so you'd reference '$._FUNCTIONS.getInfo', not 'getInfo'.

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
Explorer ,
Apr 20, 2022 Apr 20, 2022

Copy link to clipboard

Copied

Hello Bruce! 

I tried referencing the function as you stated, but I am not printing anything out to the debug console except for the "hello" before I call evalScript().

This is my js code right now:

Screen Shot 2022-04-20 at 4.51.51 PM.png

This is my jsx code:

Screen Shot 2022-04-20 at 4.53.01 PM.png

Ideally, getInfo() should return "hi" and then be printed out to the console, but at the moment it's not working. If I change .getInfo() to .printHi() though, it does print "hi" which is very puzzling. Thank you!

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
Adobe Employee ,
Apr 22, 2022 Apr 22, 2022

Copy link to clipboard

Copied

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
Explorer ,
Apr 26, 2022 Apr 26, 2022

Copy link to clipboard

Copied

I checked the post and they cited another post that helped them solve the issue. However, the one that they cited doesn't exist anymore, and they solved their problem by removing a manifest reference to an empty jsx file, which for me isn't empty. I tried to debug the code again and then I found out that the getInfo works when I just have a return "hi" statement, but fails to return anything when I copy my extendscript code into the function. I checked my extendscript code separately using the debugger before and it works, so is there anything else that would cause the return to fail? Thank you!

Screen Shot 2022-04-26 at 5.37.07 PM.png

^fails

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
Adobe Employee ,
Apr 27, 2022 Apr 27, 2022

Copy link to clipboard

Copied

That makes no sense.

 

Send me the actual extension, please.

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
Explorer ,
Apr 27, 2022 Apr 27, 2022

Copy link to clipboard

Copied

The link isn't working for me

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
Adobe Employee ,
Apr 27, 2022 Apr 27, 2022

Copy link to clipboard

Copied

LATEST

Weird; the link is just my email address. 🙂 

bbb@adobe.com

 

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 ,
Apr 19, 2022 Apr 19, 2022

Copy link to clipboard

Copied

Your original post is only tagged with "How to." Tag it also with "SDK."

 

Stan

 

@Bruce Bullis 

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