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

Trigger app.close() from afterOpen event -

New Here ,
Sep 01, 2022 Sep 01, 2022

Copy link to clipboard

Copied

Hii 

i have a script which checks for all the broken links. If i find a broken link i want to close the current document. 

I tried with app.close() from within the afterOpen event. and i get an error "cannot close document because it is the target of  an active event".
how do i stop the propagation of the event or a workaround to trigger the close of document from wthin the event.

TOPICS
Scripting

Views

99

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 ,
Sep 01, 2022 Sep 01, 2022

Copy link to clipboard

Copied

Hi,

 

I am not sure this would be a good idea, how could you ever fix the document if you close it when it has a broken link, everytime you open the document your afterOpen would fire, and then your document would close, so you could never open the document to fix the broken link.

 

Maybe I am misunderstanding your use case but this would certainly not be considered good user experience if the document opens and then closes and I wouldn't know why.

 

But I guess you could store something from the afterOpen event globally, and then have a script that runs every so often ( not sure what the best method for that would be) and if the global variable is set (with say a document name) it could close that document.

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 ,
Sep 01, 2022 Sep 01, 2022

Copy link to clipboard

Copied

LATEST

Hi @Ajith5F94 ,

technically spoken, workflow issues aside, you could open the document from app without a visible layout window so that the user has no direct access. Why that should be or not is a different discussion.

var myDoc = app.open( DocFile , false );

Then do your checks on broken links. Alert the user that the document has issues that should not be fixed right now and he/she should work on a different one. Now close the document without saving:

myDoc.close( SaveOptions.NO );

In case all is ok with the invisible document add a layout window to the invisble document with:

myDoc.windows.add();

Now the user is able to see the layout window of the opened document.

 

Hm. That all said…

This is a workflow where the actual user absolutely has no business with correcting broken links.

 

Regards,
Uwe Laubender
( Adobe Community Professional )

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