3 Replies Latest reply on Sep 4, 2018 9:36 AM by Laubender

    save user input for next script execution

    elhodel Level 1



      I just started with writing Scripts for InDesign, and was wondering, if it is possible to save the values the User entered in my Dialog and use them as defaults when he executes the script next time?

      It would be nice, if you could save them in the indd-file he was using the script, so when he is opening the indd-file again his defaults still persist.

      But its also ok if the values only persist for the duration of one session.


      Do you have any advices?



        • 1. Re: save user input for next script execution
          TᴀW Adobe Community Professional & MVP

          Sure it's possible. The simplest way to do it is to write a document label:


          myDocument.insetLabel("Animal Selected", "Cow");


          This can then be extracted as so:


          myDocument.extractLabel("Animal Selected");


          The beauty is that document labels are stored alongside the document, so any time the user opens that document, their choices can be read.

          It is also possible to store a label in the application itself -- in the same way as above.

          So it's up to you to decide whether you want the user's choices to be document-specific or application-specific.



          2 people found this helpful
          • 2. Re: save user input for next script execution
            elhodel Level 1

            Brilliant! I will test this!

            Are there any naming convention i should consider, so i don't interfere with other scripts or indesign itself?

            • 3. Re: save user input for next script execution
              Laubender Adobe Community Professional & MVP

              Hi elhodel ,

              there is one key word with insertLabel() you should be aware of.
              And that is the string "Label".


              With that you do a "Script Label" entry the user is able to see if done on a regular item on the page like a rectangle or a text frame.


              Before running the snippet just select a rectangle on the page:


              app.selection[0].insertLabel( "Label" , "Message not hidden anymore from the UI.");
              app.selection[0].label // Returns string "Message not hidden anymore from the UI."


              Open the Script Label Panel to inspect the value of property "label" of the selected rectangle: