8 Replies Latest reply on Apr 3, 2015 5:04 AM by Laubender

    [ESTK] somehow is puzzling: Throwing strange errors on some properties

    Laubender Adobe Community Professional & MVP

      Hello together!

       

      Yesterday I had some odd results by using the ESTK on a selection of a TextBox form field object.

       

      Namely reading out values for the following properties:

       

      fontSize

      required
      scrollable

       

      Other properties were fine.

      The above three were throwing strange errors.

       

      The error message from my German ESTK (ExtendScript Toolkit) was:

      "Der Inhalt dieses Objekts hat mehrere Werte für das Grafikattribut"

       

      Roughly translated:

      "The contents of this object has multiple values for the graphic attribute"

       

      This morning I could not detect any problems with the above three properties. Somehow ( magically ;-) ) now they all are addressable, values can be read out, values can be set.

      Can someone shed some light on this error message?

       

      Uwe

       

      InDesign CS6 v8.0.2

      InDesign CC v9.2.2

      InDesign CC-2014 v10.0.0

       

      ESTK 4.0.0.1 ExtendScript 4.5.5 ScriptUI 6.2.2

      Mac OSX 10.7.5 (German)

        • 1. Re: [ESTK] somehow is puzzling: Throwing strange errors on some properties
          Laubender Adobe Community Professional & MVP

          I went on with testing and the problem happened again!

          This time with the property:

           

          description


          Somehow I am inclined that this kind of error has a connection with using the property property too extensively?!

           

          So I restarted my machine. Problem is still there.

          Next I was doing was a for( x in app.selection[0]){} combined with a $.writeln() to check the selected object and track down something usable.

           

          var myObject = app.selection[0];
          for(x in myObject){
              try{
                  $.writeln(x+"\t"+myObject[x]);
                  }catch(e){$.writeln("ERROR"+"\t"+x+"\t"+e.message)};
              };
          

           

          What happened?
          Here the relevant results for this run:

               

          ERRORactiveStateIndexactiveStateIndex
          ERRORscrollableDer Inhalt dieses Objekts hat mehrere Werte für das Grafikattribut.
          ERRORdescriptionDer Inhalt dieses Objekts hat mehrere Werte für das Grafikattribut.
          ERRORallowOverridesDiese Eigenschaft ist im aktuellen Status nicht zutreffend.
          ERRORstrokeCornerAdjustmentDiese Eigenschaft ist im aktuellen Status nicht zutreffend.
          ERRORstrokeDashAndGapDiese Eigenschaft ist im aktuellen Status nicht zutreffend.
          ERRORoverprintStrokeDiese Eigenschaft ist im aktuellen Status nicht zutreffend.
          ERRORoverprintGapDiese Eigenschaft ist im aktuellen Status nicht zutreffend.

           

          Translation of the error messages:

           

          Der Inhalt dieses Objekts hat mehrere Werte für das Grafikattribut.

          The contents of this object has multiple values for the graphic attribute.

           

          Diese Eigenschaft ist im aktuellen Status nicht zutreffend.

          This property is not applicable in the current state.

           

           

          The first error is explainable, the five ones at the end of the list are explainable as well.
          What is not explainable (for me) is the error with scrollable and description.

          (Remember the last time I had this error also with the properties required and fontSize. Not so this time.)

           

          So what to make out of this?
          What is it the next time with the object textBox and its properties?

           

          Uwe

          • 2. Re: [ESTK] somehow is puzzling: Throwing strange errors on some properties
            Laubender Adobe Community Professional & MVP

            Next try: I added a new TextBox to the page and ran the for x in-loop.
            This time I had problems with:

             

            scrollable

            fontSize

             

            Error message for both: "The contents of this object has multiple values for the graphic attribute"

             

            And: the property description is missing altogether in the aquired list.
            (Note: the value for "description" was not defined this time when I added the TextBox to the page.)

             

            Uwe

            • 3. Re: [ESTK] somehow is puzzling: Throwing strange errors on some properties
              Pickory Level 3

              Have you got any exotic plugins installed?

               

              P.

              • 4. Re: Re: [ESTK] somehow is puzzling: Throwing strange errors on some properties
                Laubender Adobe Community Professional & MVP

                @Pickory – Good question…
                Removed one possibly exotic one from CS6, restarted.
                Same problem.

                 

                But also the same results from InDesign CC and CC-2014 where I never istalled 3rd party plugins.

                 

                If you like you could run the following test.

                It will:

                 

                1. Add a new document

                2. Add a new TextBox

                3. Cycles through all properties of that TextBox

                4. Adds a page

                5. Adds a text frame on that page

                6. Writes the results to that text frame

                7. Converts the results to a table

                 

                CS6 and above !

                 

                var myDoc = app.documents.add();
                var myTextBox = myDoc.textBoxes.add();
                var counter = 0;
                var myResultString = "";
                
                var myObject = myTextBox;
                
                for(x in myObject){
                   
                    counter++
                   
                    try{
                        //$.writeln(counter+x+"\t"+myObject[x]);
                        myResultString = myResultString+String(counter+"\t"+x+"\t"+myObject[x]+"\r");
                       
                        }catch(e){
                           
                        //$.writeln("ERROR"+"\t"+x+"\t"+e.message)
                        myResultString = myResultString+String("ERROR"+"\t"+x+"\t"+e.message+"\r");
                       
                        };
                    };
                
                myDoc.pages.add();
                var myTextFrame = myDoc.pages[1].textFrames.add({geometricBounds:myDoc.pages[1].bounds});
                myTextFrame.parentStory.texts[0].insertionPoints[0].contents = myResultString;
                myTextFrame.parentStory.texts[0].convertToTable("\t","\r");
                

                 

                 

                Uwe

                • 5. Re: Re: [ESTK] somehow is puzzling: Throwing strange errors on some properties
                  Laubender Adobe Community Professional & MVP

                  In the meanwhile Pickory was testing my snippet and the problem was revealed also on his machine.
                  Now that I know the exact English version of the error message, not far from my rough translation*, I searched the web for something similar and came up with something I should have known (silly me, could have thought about this before):

                   

                  Kasyan Servetsky

                  [JS CS6] Is anybody able to get button’s printableInPdf property?

                  Apr 13, 2013 9:58 AM

                  https://forums.adobe.com/message/5253040

                   

                  A fruitful discussion span around this problem then, and I indeed – shame on me that I forgot about that – partcipated a bit…

                  Roland (drerol74) was spot on with his comment in #5, Trevor provided a solution in #7, Kasyan refined this for his purposes.

                   

                  Roland: "It's a bit like Schrödinger's cat, maybe Adobe's Cat. Only when you change the value, you know the value ;-)"

                  Kasyan: "If the printableInPdf property wasn’t changed by the user/script, it throws the error while trying to access it. In this case we set it to true in the “on error” block because that’s the default value for every button."

                   

                  To sum it up (my interpretation):

                  1. If you are scripting form fields, be aware that something can be broken if you try to access properties.
                  2. In case you hit a broken property the default value of a property is in place.

                  3. Now what is the default? The default value is the value shown to the user in the GUI of InDesign when working with form fields and new objects are converted with the form fields panel.

                   

                  So I have to rethink my ways scripting form fields.
                  Ah. Let's see what goes under the superclass of FormField:

                   

                  Button, CheckBox, ComboBox, ListBox, MultiStateObject, RadioButton, SignatureField, TextBox

                   

                  Finally: What can I say?

                  "Expect the unexpected…"

                   

                  Uwe

                   

                  * "The content of this object has multiple values for this graphic attribute."

                  • 6. Re: [ESTK] somehow is puzzling: Throwing strange errors on some properties
                    Marc Autret Level 4

                    Hi Uwe,

                     

                    In my opinion this is a bug. ID CS6 to CC does not properly manage access to FormField properties as soon as there is a conflict between the default Buttons and Forms panel settings and what is done through scripting.

                     

                    As a very first test you can check that using myObject = myTextBox.properties in your snippet won't generate errors anymore, since all failing properties (fontSize, multiline, etc.) are not considered available at all in the TextBox instance.

                     

                    Interestingly, all these properties become fully functional (read & write access) when explicitly set at creation time:

                     

                    var TB = {
                        description: 'foobar',       // default: ''
                        fontSize: 16,                // default: 0
                        hiddenUntilTriggered: true,  // default: false
                        multiline: true,             // default: false
                        name: 'myTextBox',           // default: auto
                        password: true,              // default: false
                        readOnly: true,              // default: false
                        required: true,              // default: false
                        scrollable: true,            // default: false
                        };
                    
                    var doc = app.activeDocument,
                        tb = doc.textBoxes.add(TB),
                        k,
                        a = [];
                    
                    for( k in TB )
                        {
                        a[a.length] = k + ': ' + tb[k]; // no issue
                        }
                    
                    alert( a.join('\r') );
                    

                     

                    However, if the user change any of these via the Buttons and Forms panel, there is good chance that the "multiple values" error re-appears when the script attempts to read the modified property. For instance, if the user manually changes the TextBox description to any non-empty string, I don't see any workaround to safely access that custom value. There are also problems with defaults in various circumstances.

                     

                    So my assumption is that there is a sync issue between GUI settings and their reflexion in the scripting DOM—especially when no behaviors and/or states are defined for the control.

                     

                    @+

                    Marc

                    • 7. Re: [ESTK] somehow is puzzling: Throwing strange errors on some properties
                      Laubender Adobe Community Professional & MVP

                      Hi Marc,

                      thank you for testing. Indeed there are circumstances where some properties are missing in the TextBox instance. This is really a bug.

                       

                      But not only for us scripters!

                       

                      I assume that this bug is affecting also the export feature for IDML and IDMS.

                      An avarage user will be hit, if using form fields with IDML and IDMS.

                       

                      Some values will not be exported. Just try it with a single text box where all properties are set. Export to IDML and reopen again in the same version of InDesign. Some settings are gone. Inspecting the code of IDML is showing that the missing settings were not written to IDML. "Description" will never make it to IDML or IDMS. And the crazy thing is: If you leave the entry field for "Description" blank, IDML will get a "Description" field set to an empty string.


                      And that means working with library documents is also affected. Storing form fields in library *.indl files will change the values set with text boxes. Libraries are using IDMS as asset format.

                       

                      Uwe

                      • 8. Re: [ESTK] somehow is puzzling: Throwing strange errors on some properties
                        Laubender Adobe Community Professional & MVP

                        Now a follow-up on all the problems with FormField objects.
                        As to my knowledge and testing, these issues should be fixed in:

                         

                        InDesign CC v9.3.0

                        InDesign CC-2014.2 v10.2.0

                        CC Simple Save Back Service (the IDML related problems)

                         

                        The problems are not fixed in CS6 v8.1.0.

                         

                        However, naturally I could not test everything. So be careful.
                        If still bugs with scripting FormField objects do pop up, please update this thread here.

                         

                        Thank you.

                         

                        Uwe