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

Need a support to develop InDesign Script

Explorer ,
Sep 07, 2021 Sep 07, 2021

Copy link to clipboard

Copied

Hi team,

 

Support me to finish the script. 

Basically I'm not from a Java or coding backround. but always ready to learn new things and explore the challenge.

 

I wish to create or find a indesign Script like  the below brief

 

Type: Confirm box pop

like this

 

checklist image.png

 

 I create the above popup with the help of  some blogs.

 

Why I need this script.

I'm Planning this script for my team, if incase the designer missed out or forgot the comments or any guideline in file,  the script will remind everything.

so we can avoid the errors,

 

How the scripts needs to function.

Once the designer try to save their indesign file the script popup will come first and ask questionswith yes or no options. example: Did you check the client comments? Yes/No    |    Did you check the Brand Guidlines? Yes/No etc..

 

What I tried  and Where i stuck 

I almost near to my dream script

I made the complete Popup box with basic functionalities 

For example: if  the designer Click YES  button the next question will popup, If they Click NO the alert  popup like: please check needed things.

 

Where i need a support 

I Need to overight  the save and save as command in indesign.

Usually when we save the document using shortcuts or manually it will atomatically move to the Document Saving option..

But what i need exactly 

Once we try to save the file the checklist popup needs to appere first once we done with checklist  then only the Save Option should Pop.

 

Note : No one can save the document without crossing the checklist.

 

 

Kindly share your ideas and opinions

 

Thanks in advance 

Regards

Nousheeth Iqbal 

 

 

 

 

 

TOPICS
Feature request , Import and export , Scripting , SDK

Views

426

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

correct answers 3 Correct answers

Advocate , Sep 07, 2021 Sep 07, 2021

Hi @Nousheeth ,

Try this snippent & if further questions need you can add it in confirm dialog & store it into ans variable.

 

/////////////////////////////////////////////////////////////////////////////////////////////////////

#targetengine "session"

// Listen for the save event
app.addEventListener('beforeSave', saveFile, false);
app.addEventListener('beforeSaveAs', saveFile, false);
app.addEventListener('beforeSaveACopy', saveFile, false);

///////////////////////////////////////////////////////

...

Votes

Translate

Translate
Advocate , Sep 07, 2021 Sep 07, 2021

If you are looking for better UI, then try this:

#targetengine "session"
/////////////////////////////////////////////////////////////////////////////////////////////////////
function saveFile(event) {
    var dialog = new Window("dialog"); 
        dialog.text = "Checklist reminder"; 
        dialog.orientation = "column"; 
        dialog.alignChildren = ["center","top"]; 
        dialog.spacing = 10; 
        dialog.margins = 16; 
    var group1 = dialog.add("group", undefined, {name: "group1"
...

Votes

Translate

Translate
Advocate , Sep 09, 2021 Sep 09, 2021

You need to put this script in startupFolder.

For example : C:\Program Files\Adobe\Adobe InDesign CC 2019\Scripts\startup scripts

Under this folder you need to keep the code & need to restart the application.

After that if you try to save any file pop-up will come up.

 

Best

Sunil

Votes

Translate

Translate
Community Expert ,
Sep 07, 2021 Sep 07, 2021

Copy link to clipboard

Copied

Would be helpful to show existing code, but what you're looking for are Event Listeners that you can attach to your popup function that are called during the beforeSave event. An example of a beforeSave event listener can be found here: 

https://community.adobe.com/t5/indesign-discussions/beforesave-or-aftersave-eventlisteners/m-p/10921...

Then you can use preventDefault and/or stopPropagration methods of the event to cancel the save in the event that the checklist is not executed. See: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Event.html

 

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
Advocate ,
Sep 07, 2021 Sep 07, 2021

Copy link to clipboard

Copied

Hi @Nousheeth ,

Try this snippent & if further questions need you can add it in confirm dialog & store it into ans variable.

 

/////////////////////////////////////////////////////////////////////////////////////////////////////

#targetengine "session"

// Listen for the save event
app.addEventListener('beforeSave', saveFile, false);
app.addEventListener('beforeSaveAs', saveFile, false);
app.addEventListener('beforeSaveACopy', saveFile, false);

/////////////////////////////////////////////////////////////////////////////////////////////////////
function saveFile(event){
    var ans = false;
    ans = confirm ("Did you check the client comments?", true, "Checklist Reminder...");
    if(ans){
        ans = confirm ("Did you check the Brand Guidlines?", true, "Checklist Reminder...");
        if(ans){
            ans = confirm ("Answer next question?", true, "Checklist Reminder...");
            }
        }
    if(!ans){
        event.preventDefault();
        }
    }
/////////////////////////////////////////////////////////////////////////////////////////////////////

Best

Sunil

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
Advocate ,
Sep 07, 2021 Sep 07, 2021

Copy link to clipboard

Copied

If you are looking for better UI, then try this:

#targetengine "session"
/////////////////////////////////////////////////////////////////////////////////////////////////////
function saveFile(event) {
    var dialog = new Window("dialog"); 
        dialog.text = "Checklist reminder"; 
        dialog.orientation = "column"; 
        dialog.alignChildren = ["center","top"]; 
        dialog.spacing = 10; 
        dialog.margins = 16; 
    var group1 = dialog.add("group", undefined, {name: "group1"}); 
        group1.preferredSize.width = 85; 
        group1.orientation = "column"; 
        group1.alignChildren = ["left","center"]; 
        group1.spacing = 10; 
        group1.margins = 0; 
    var group2 = group1.add("group", undefined, {name: "group2"}); 
        group2.orientation = "row"; 
        group2.alignChildren = ["left","center"]; 
        group2.spacing = 10; 
        group2.margins = 0; 
    var checkbox1 = group2.add("checkbox", undefined, undefined, {name: "checkbox1"}); 
        checkbox1.text = "Did you check the client comments?"; 
        checkbox1.preferredSize.width = 300; 
    var group3 = group1.add("group", undefined, {name: "group3"}); 
        group3.orientation = "row"; 
        group3.alignChildren = ["left","center"]; 
        group3.spacing = 10; 
        group3.margins = 0; 
    var checkbox2 = group3.add("checkbox", undefined, undefined, {name: "checkbox2"}); 
        checkbox2.text = "Did you check the Brand Guidlines?"; 
        checkbox2.preferredSize.width = 300; 
    var group4 = group1.add("group", undefined, {name: "group4"}); 
        group4.orientation = "row"; 
        group4.alignChildren = ["left","center"]; 
        group4.spacing = 10; 
        group4.margins = 0; 
    var checkbox3 = group4.add("checkbox", undefined, undefined, {name: "checkbox3"}); 
        checkbox3.text = "Next Question....?"; 
        checkbox3.preferredSize.width = 300; 
    var divider1 = dialog.add("panel", undefined, undefined, {name: "divider1"}); 
        divider1.alignment = "fill"; 
    var group5 = dialog.add("group", undefined, {name: "group5"}); 
        group5.orientation = "row"; 
        group5.alignChildren = ["right","center"]; 
        group5.spacing = 10; 
        group5.margins = 0; 
        group5.preferredSize.width = 300; 
    var button1 = group5.add("button", undefined, undefined, {name: "Ok"}); 
        button1.text = "Proceed"; 
        button1.preferredSize.width = 100; 
        button1.visible = false;
    var button2 = group5.add("button", undefined, undefined, {name: "button2"}); 
        button2.text = "Cancel"; 
        button2.preferredSize.width = 100; 
        checkbox1.onClick = function (){
            if(checkbox1.value && checkbox2.value && checkbox3.value) button1.visible = true;
            else button1.visible = false;
            }
        checkbox2.onClick = function (){
            if(checkbox1.value && checkbox2.value && checkbox3.value) button1.visible = true;
            else button1.visible = false;
            }
        checkbox3.onClick = function (){
            if(checkbox1.value && checkbox2.value && checkbox3.value) button1.visible = true;
            else button1.visible = false;
            }

    if(dialog.show() != 1){
        event.preventDefault();
        }
    }
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Listen for the save event
app.addEventListener('beforeSave', saveFile, false);
app.addEventListener('beforeSaveAs', saveFile, false);
app.addEventListener('beforeSaveACopy', saveFile, false);
/////////////////////////////////////////////////////////////////////////////////////////////////////

Best

Sunil

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 ,
Sep 08, 2021 Sep 08, 2021

Copy link to clipboard

Copied

Hi sunil, 

Thanks for your time 

 

When i try to run the script there is no changes happened. 

I think Your script is correct, 

I have an issue with how to run 

 

How I tried:

First  i copy the codes and  pasted in notepad the saved as a JSX  file.

Pasted in respective Script folder.

 

Then i run the script, there is no response 

 

can you explain how can i run the script 

 

Awaiting for your Reply

Nousheeth

 

 

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
Advocate ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

You need to put this script in startupFolder.

For example : C:\Program Files\Adobe\Adobe InDesign CC 2019\Scripts\startup scripts

Under this folder you need to keep the code & need to restart the application.

After that if you try to save any file pop-up will come up.

 

Best

Sunil

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 ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

Dear Sunil,

I am gratefull to you that you are helping me a lot in the scripts.

I have informed few of my friends that you are master,

I really appreciate for the  time and effort you have dedicated to help me.

 

It is working perfectly with SAVE & SAVE AS option.

There is a small looping error, while we export the file as a package, we are getiing 3 times checklist Popup  to complete the task. please check the script which you provided & please help me to solve this error. 

 

Waiting for reply
Regards,
Nousheeth

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
Advocate ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

Hi @Nousheeth ,

You are kind with your words.
At mean time, for repeated alert is concerned.
This is modified code.

/////////////////////////////////////////////////////////////////////////////////////////////////////

#targetengine "session"

// Listen for the save event
app.addEventListener('beforeSave', saveFile, false);
app.addEventListener('beforeSaveAs', saveFile, false);

/////////////////////////////////////////////////////////////////////////////////////////////////////
function saveFile(event){
    var ans = false;
    ans = confirm ("Did you check the client comments?", true, "Checklist Reminder...");
    if(ans){
        ans = confirm ("Did you check the Brand Guidlines?", true, "Checklist Reminder...");
        if(ans){
            ans = confirm ("Answer next question?", true, "Checklist Reminder...");
            }
        }
    if(!ans){
        event.preventDefault();
        }
    }
/////////////////////////////////////////////////////////////////////////////////////////////////////

Best

Sunil

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
Advocate ,
Sep 10, 2021 Sep 10, 2021

Copy link to clipboard

Copied

LATEST

Reason of three alert is that "beforeSaveACopy" event uses "beforeSaveAs" event so previous event is invoked by that. That was the reason for tripple alert.

 

Now Check & see.

 

Best

Sunil

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