7 Replies Latest reply on Nov 7, 2015 7:19 AM by dburnham

    Hey, developers!  How would you track button use?

    pasleeth

      Supposing you had a button on a particular layout that activates a script, and you wanted to track the number of times it was clicked during a given interval of time, like yesterday, last week, or next month.

       

      How would you go about setting up such a feature?

       

      Andrew

        • 1. Re: Hey, developers!  How would you track button use?
          mikebeargie

          you just need simple logging. It should be as easy as writing a script that takes some parameters and saves them to a "log" table that you setup.

           

          EG: log script:

          Set Variable [ $p ; get(scriptparameter) ]

          go to layout [ log ]

          new record/request

          set field [ log::text ; $p ]

          go to layout [ original layout ]

           

          EG: then add this to your button script:

          Perform Script [ log script ; parameter: "button name" ]

          • 2. Re: Hey, developers!  How would you track button use?
            ninja

            Create a tracking field

            Insert one step into the script that is launched....

             

            SetField ( Table::TrackingField ; Table::TrackingField & CR & Get(Accountname) & " " & Get(CurrentTimestamp) )

            {CR is carriage return}

             

            You'll then have a list of who and when that you can parse as you see fit.

            • 3. Re: Hey, developers!  How would you track button use?
              taylorsharpe

              Mike and Eric give you two different ways of doing this.  Mike's is storing the info in a table that doesn't even have to be related.  Eric's is storing the information in a single field of the same record.  Eric's is quick and simple, but is not easily searchable since you can have multiple values in the same field.  Eric's is also useful if you want to tie the use of that button to a record.  Otherwise it is not useful. Or maybe the tracking field is in a related table that you have to set up the relationship.  And as noted in Eric's calc, he added more info like the AccountName in the stored value, which might be more useful.  I guess the question may be more about what you want the recorded information to store and tell about the button's use (e.g., who used it?  when?  or just that it was used?).

              • 4. Re: Hey, developers!  How would you track button use?
                mikebeargie

                My method you can just add a number of auto-enter fields to the "log" table that will give you useful metadata. Like creation account name, creation time stamp. You can also add parameters, I was just posted a simple example.

                 

                It's also context free, so you can use it to log multiple events from multiple locations throughout your system.

                 

                The only real "gotcha" is running the log script if you have layout script triggers that would throw it off during the log creation.

                • 5. Re: Hey, developers!  How would you track button use?
                  sreese

                  We do ours a bit more complex.

                   

                  For any button script we add a second script as the first step -

                   

                  Perform Script ( Log Usage ) - Parameter ( Button Name)    #it is contained in a seperate log file

                   

                  Script Log Usage

                   

                  Freeze Window

                   

                  Set Variable $user = get ( AccountName)

                  Set variable $layout = get ( LayoutName )

                  Set variable $file = get ( fileName )

                   

                  Go to layout log

                  Insert appropriate data

                   

                  Close Window

                  Maximize

                   

                  Or something to that effect anyway. I can capture as much or as little data as I need in that case.

                  • 6. Re: Hey, developers!  How would you track button use?
                    pasleeth

                    Thanks, guys.  You've each been helpful offering something I can use now for my immediate needs or farther down the road on other projects.

                     

                    Andrew

                    • 7. Re: Hey, developers!  How would you track button use?
                      dburnham

                      I would also add    get(ActiveLayoutObjectName) to try to get hold of the button's object name when it is clicked to avoid having to type it every time I insert the script steps Mike described.  That way the log script could be entered as a Perform Script step with no other editing. 

                       

                      And if we could someday save that Perform Script as a favorite it would be even better.