9 Replies Latest reply on Jun 7, 2012 12:20 PM by jtcdesigns1

    Data Merge arrangeBY not working

    jtcdesigns1 Level 1

      I'm new to scripting in InDesign CS5.5 but I know other languages. I have a script that I wrote with javascript in ExtendScript that automatically does a datamerge and saves out to PDF. My problem is I want to arrange the records by columns.

       

      I've read the documentation in the Object Model Viewer which shows me

       

      DataMergePreference.arrangeBy

       

      and I found a site online that shows me what values can go in it... in my case it would be     columns_first

       

       

      however I can't get it to work. I keep getting errors left and right with any way I try using arrangeBY

       

      Anything I attempt to try using DataMergePreferences or DataMergePreference  I get Error Number 55  Object does not support the property of the method 'dataMergePreferences' or 'dataMergePreference'

       

      if I try  myDocument.dataMergeProperties.arrangeBy.   I get Object does not support arrangeBy

       

       

      I can't find any examples anywhere of people wanting to use arrangeBy

       

      if anyone out there has used it I would be greatly appreciative to know how to write that one line to arrange by column which will probably help me figure out many other things. I'll accept links if anyone knows of any that can help.

       

      So far I've had no luck with the inDesign CS5 JS scripting guide or reference.

        • 1. Re: Data Merge arrangeBY not working
          Marijan Tompa [tomaxxi] Level 4

          Try:

           

          myDocument.dataMergeProperties.dataMergePreferences.arrangeBy = ArrangeBy.ROWS_FIRST;

           

          Hope that helps.

           

          --

          Marijan (tomaxxi)

          http://tomaxxi.com

          1 person found this helpful
          • 2. Re: Data Merge arrangeBY not working
            absqua Level 4

            It looks like you want:

             

            myDocument.dataMergeProperties.dataMergePreferences.arrangeBy = ArrangeBy.COLUMNS_FIRST;

             

            (The way I tracked down the property hierarchy was to go to http://jongware.mit.edu/idcs5.5js_html/idcs5.5js/inxx.html#D, look for DataMergePreference, click on that, see that its parent is a DataMerge object, click on that, see that its parent is a Document, click on that, do a find for DataMerge, see that dataMergeProperties is the property of Document that requires a DataMerge object, click back down to get to arrangeBy as a property of DataMergePreference, and see what properties the ArrangeBy enumerator has as options. Self-explanatory!)

             

            Jeff

            • 3. Re: Data Merge arrangeBY not working
              jtcdesigns1 Level 1

              Thank you BOTH!!! I wish I could have marked you both as correct so I had to go with the first one who posted.

               

               

              I have another question. the first line in my datamerge is    app.open(File("/path/to/datamergedoc.indd"));

               

              it gets flagged as   app.open is not a function when I run it in ExtendScript. If I open indesign and then run the script it works completely fine. Do I need to specify the actual app to open? I also have an app.doScript to run some applescript within javascript which works fine but also doesn't work when I hit run in Extend Script.. Maybe its the same issue?

              • 4. Re: Data Merge arrangeBY not working
                absqua Level 4

                You need to choose InDesign from the target dropdown if you're running it from the ESTK. (Or use "#target indesign;" at the top of your script.) That should fix both of your problems: the ESTK has neither an open() nor a doScript() function.

                1 person found this helpful
                • 5. Re: Data Merge arrangeBY not working
                  jtcdesigns1 Level 1

                  If no one recently has called you awesome... then right now I am calling you awesome!

                   

                  I remember seeing that in some samples before but in other ones I didn't because people were calling it from InDesign. Thanks for everything

                  • 6. Re: Data Merge arrangeBY not working
                    absqua Level 4

                    Glad to be of help. FWIW, I prefer to just choose the right application from the drop-down rather than using the #target statement. If you use the latter, the ESTK will ask you if you want to actually run the script every time you open it for editing.

                    1 person found this helpful
                    • 7. Re: Data Merge arrangeBY not working
                      jtcdesigns1 Level 1

                      So far things are working but my data isn't merging. That I believe isn't a fault of InDesign or the script. We have an automation system called FullSwitch... I have a task that tells InDesign to open and run the script I wrote.. The problem there is figuring out how its running the script and I think its closing the merged document because when I do have it run it seems to save a pdf of the original indesign file that has the tags for the merged data. If I could find a way in apple script to open the script I wrote in ExtendScript then I would be estatic.

                       

                      You mention choosing the right application from the drop down.. is there a way to run the script as soon as I open it in Extend Script? If that is something I can write into the script then all.. or most of my problems will be solved.

                      • 8. Re: Data Merge arrangeBY not working
                        absqua Level 4

                        jtcdesigns1 wrote:

                         

                        ...If I could find a way in apple script to open the script I wrote in ExtendScript then I would be estatic... You mention choosing the right application from the drop down.. is there a way to run the script as soon as I open it in Extend Script? If that is something I can write into the script then all.. or most of my problems will be solved.

                         

                        Sorry, I don't know anything about FullSwitch. If using it to call an Applescript would work better, maybe you could use do script:

                         

                        tell application "Adobe InDesign CS5.5"

                          set myScript to POSIX file "/path/to/datamerge_script.jsx"

                          do script myScript language javascript

                        end tell

                        1 person found this helpful
                        • 9. Re: Data Merge arrangeBY not working
                          jtcdesigns1 Level 1

                          You deserve some sort of award. Works great. Now I can do all the scripting I want within the jsx I made.