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

How to pass the arguments from JSX to UXP Script

Explorer ,
Sep 19, 2023 Sep 19, 2023

Dear all,

 

I'm writing the code using Extend Script (JSX) and planning to call the UXP script with Arguments, through doScirpt mode

 

//==================================================//

var argsArray = ["Hariharasudhan", "test1", "test1", "process done"];
 var Processing_connectURL = app.doScript("/Applications/Adobe InDesign 2023/Scripts/Scripts Panel/Workflow_Development/InDesignSource/createsh.idjs", 1431522407, argsArray);
 
//==============================================//
 
But I received the "createsh.idjs" file 
 
//===========================//
const script = require("uxp").script;
alert(script.args);
//===============================//
 
showing alert is empty.
 
Kindly resolve any one, really I will appriciate 
 

 

 

TOPICS
Scripting , UXP Scripting
1.6K
Translate
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

correct answers 1 Correct answer

Community Expert , Sep 20, 2023 Sep 20, 2023

Could it be that the problem is that you are passing the idjs path as a string during doScript? If you pass File, it might succeed. I have had success with this script.

 

// caller.jsx

var argsArray = ['argString', 20, true] ;
var idjsFile = new File('~/Desktop/callee.idjs') ;
var res = app.doScript(idjsFile, ScriptLanguage.UXPSCRIPT, argsArray, UndoModes.ENTIRE_SCRIPT) ;

 

// callee.idjs

const { app } = require('indesign') ;
const { script } = require('uxp') ;

const alert = (msg) => {
  cons
...
Translate
Engaged ,
Sep 19, 2023 Sep 19, 2023

I know the 131522407 number is associated with "ScriptLanguage.UXPSCRIPT" in the UXPscript doScript, but I don't know if it would also work with extendscript. I would try to replace it with the actual text and see if that gets it for you.

Translate
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
Engaged ,
Sep 19, 2023 Sep 19, 2023

Are you going to return data from the UXP script? if not, you should not have to make variable declaration for the doScript.

Translate
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 ,
Sep 19, 2023 Sep 19, 2023

Dear John,

 

Thank you, 

 

We tried the below options also, but Unable to get the argument values from JSX to UXP scripts.

//==========================//
var argsArray = ["Hariharasudhan", "test1", "test1", "process done"];
  app.doScript("/Applications/Adobe InDesign 2023/Scripts/Scripts Panel/Workflow_Development/InDesignSource/createsh.idjs",ScriptLanguage.UXPSCRIPT, argsArray);
 
//============================//
 
We aware that, JSX to JSX will pass the arguments and easy to get the argument values. the same they mentioned UXP Script to UXP Script.
 
But we required JSX to UXP. 
 
Kindly resolve any other way to sort this issue.....
 
Thanks & Regards
Harihara Sudhan T R
 
Translate
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
LEGEND ,
Sep 19, 2023 Sep 19, 2023

Just use Label option - on the Document level. 

 

Translate
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 ,
Sep 19, 2023 Sep 19, 2023

Dear Robert,

 

Thank you for giving the solutions. We are also thinking the least options.

Means, we will update the data into the Document Label information (store in document frame or any conditional variables).

from UXP script will read it from the Document and run the UXP script.

Will plan to only execute the UXP script from JSX script.

 

We tried to do for ID-Tasker ... But no support for Mac OS.

 

Kindly let me know any other way to resolve the issue.... really will appriciate.

 

Thanks & Regards

Harihara Sudhan T R

Translate
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
LEGEND ,
Sep 20, 2023 Sep 20, 2023

Unfortunately, for Mac users, ID-Tasker is PC only. 

 

Translate
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 ,
Sep 20, 2023 Sep 20, 2023

Could it be that the problem is that you are passing the idjs path as a string during doScript? If you pass File, it might succeed. I have had success with this script.

 

// caller.jsx

var argsArray = ['argString', 20, true] ;
var idjsFile = new File('~/Desktop/callee.idjs') ;
var res = app.doScript(idjsFile, ScriptLanguage.UXPSCRIPT, argsArray, UndoModes.ENTIRE_SCRIPT) ;

 

// callee.idjs

const { app } = require('indesign') ;
const { script } = require('uxp') ;

const alert = (msg) => {
  const dialog = app.dialogs.add() ;
  const col = dialog.dialogColumns.add() ;
  const colText = col.staticTexts.add() ;
  colText.staticLabel = '' + msg ;
  dialog.canCancel = false ;
  dialog.show() ;
  dialog.destroy() ;
  return ;
} ;

alert(script.args[0]) ;
// --> 'argString'
Translate
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 ,
Sep 20, 2023 Sep 20, 2023
LATEST

Dear Sttk3,

 

Thank you, it is working fine, will call with Argument from JSX to IDJS script. 

//=====================

let myInDesign = require("indesign");
let script = require("uxp").script;

let app = myInDesign.app;

 

let ufs = require("uxp").storage.localFileSystem;

const uxpfs = require("uxp").storage;
const shell = require("uxp").shell;

const osname = require("uxp").os;

const osInfo = require('os');

const UserHomeDirsInfo = osInfo.homedir();


let folder = await ufs.getEntryWithUrl("file:"+UserHomeDirsInfo+"/Desktop/StoryBoard_Workflow/Development/TempProcess");

 

 

try {
filePath = await folder.getEntry("connectURL.sh");
}
catch (error){
filePath = await folder.createEntry("connectURL.sh");
}

alert(script.args[0]) ;

//======================

 

But this is not working for the above code is in the IDJS script. because of the "await" function. It is mandatory to do my code of function.

 

So any other alrernate method is there, along with await functionalities in IDJS script. Mean, with arguments will work with "await" funcitons.

 

Thanks & Regards

Harihara Sudhan T R.,

Translate
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