5 Replies Latest reply on Jan 28, 2010 8:54 AM by MarkWalsh

    Return current javascript for event

    btbobby

      Does anyone know if it is possible to return the existing javascript for an event?

       

      We have a form which is modified by a 3rd party. They create a complex url call which is built up (I cannot reproduce at runtime without db access) and placed in javascript for mouse up on the button. Sometimes the url calls for data entry, sometimes for readonly. Part of the url either says 'read' or 'edit', this is the only difference.

       

      Under certain criteria, I want to make the button call read only. I was hoping that I could do that by taking existing javascript into a string, doing a simple replace for 'edit' with 'read' and then using setAction to update mouse up for the button with the modified string.

       

      Since there isn't a getAction function I'm not holding out much hope.

        • 1. Re: Return current javascript for event
          try67 MVP & Adobe Community Professional

          Not with a script. Maybe a plugin can do it.

          • 2. Re: Return current javascript for event
            MarkWalsh Level 4

            As try67 mentioned, I don't think there's anything available to do this, although I wish there was too. Where I work, sometimes a PDF form that I initially worked on is given to another coworker to make changes to, and since I'm the only one here who knows javascript, and does the bulk of the PDF forms, sometimes they can cause real problems. Often, somebody creates a new field by copying an existing field (actions, format, calculations, etc. and all) and renaming it without realizing that those other settings are there. Or, perhaps I inadvertently missed a setting on one of the fields when setting it up. Trying to chase down these problems can be a nightmare on larger forms. I would love to be able to create a report on all of the settings for the buttons/fields so that I could find out if anything is not set correctly.

             

            I hope that a future version will have a 'getAction' method to complement the 'setAction' method. It would sure make analyzing a document much easier.

            • 3. Re: Return current javascript for event
              try67 MVP & Adobe Community Professional

              Here's a suggestion: When you make a field, create a hidden text field with

              the same name+"Action" and paste the code into it.

              Then if you want to get the code for field "abc" you do this:

              code = this.getField("abcAction").valueAsString();

              You can then manipulate the code and set it back to "abc" using setAction

              and to "abcAction" using the value property.

               

              However, the downfall is that if someone changes the code without changing

              the value of abcAction (or the name of "abc"), you won't be able to know

              it...

              • 4. Re: Return current javascript for event
                btbobby Level 1

                Yeah, it's just a shame there's no getAction function. I'm limited due to the fact that it's 3rd party software which is modifying the PDF at a certain point so there's no way I can store it in a string or elsewhere.

                • 5. Re: Return current javascript for event
                  MarkWalsh Level 4

                  Thanks for the suggestion, it's an interesting idea, but I think that with 30+ and even 50+ fields, this would easily become even more troublesome than the current situation.

                   

                  And, unless I'm misunderstanding your suggestion, I'm not sure if it will help me if someone takes a field named 'Phone' and copies it and renames it 'First Name' - it will still contain all of the action settings and formatting settings that 'Phone' had, and since there wouldn't be a 'First NameAction' field, I still wouldn't be able to identify which fields are set improperly.