1 2 3 Previous Next 30 Replies Latest reply on Aug 26, 2013 1:22 PM by Matty_1

    Go to Field using a calculation

    Matty_1

      Title

      Go to Field using a calculation

      Post

           I currently have a data base with users who are weary about computers.  In the past I had the whole thing on lock down and any changes after a ticket was closed had to be done through me the administrator.  It's been a little while now so I'm trying to give the users a little more freedom so what I've done is added a script that records the contents of the currently active field upon entry and another script that compares the field contents when the user tries to exit the field.  If it's different and the ticket is closed it sets off a series of steps that records what when who where and how the change occured and kicks up a window asking for an explanation.  This all works fine and dandy but given that the trigger is on exit it messes up my tabbing.

           I'm wondering if it would be possible to save the field name (which I already know how to do) but then have a go to field using the variable I saved so that after the script runs I can return to the original field and then use go to next field to have the tab function work properly again.

            

           Let me know, thanks!

        • 1. Re: Go to Field using a calculation
          philmodjunk

               Go To Field cannot be used in that fashion. Be nice if it could, but you can't.

               You could, however, use the name box in the inspector's position tab to give each field an object name that is the same as its field name. Then you can use go to object to put the cursor into the desired field.

          • 2. Re: Go to Field using a calculation
            LaRetta_1

                 Hi Matty,

                 You can also test and then if failure, use Exit Script [ False ] which leaves the User right where they are.  OnObjectExit:  If the script returns true then the original event proceeds (user would be tabbing to next field) otherwise the event is cancelled.

                 You might also consider using OnObjectSave which makes it simple to then REVERT the changes if User changes their mind when you ask for clarification. 

            • 3. Re: Go to Field using a calculation
              Matty_1
                   

              You could, however, use the name box in the inspector's position tab to give each field an object name that is the same as its field name. Then you can use go to object to put the cursor into the desired field.

              Hi Phil, I was worried you'd say that ... I was hoping not to have to visit each object and have to give it a name.

              LaRetta, At first I started replying with quotes and all sorts of comments and questions but instead I figured maybe I should just upload my script and maybe you can shoot ideas back and forth.  You will see in my script how I resolved the REVERT issue ... I'm no pro so please feel free to suggest alternatives if you see fit.  The first time the revert step appears was to avoid look ups from updating themselves every time I entered the field and the second is if the user wants to cancel the change before being prompted to explain.

                    

              • 4. Re: Go to Field using a calculation
                Matty_1

                     second page ...

                • 5. Re: Go to Field using a calculation
                  philmodjunk

                       One trick that I have used is to use a script parameter with OnObjectEnter to capture the original value of the field in a global variable and then a script performed by OnObjectSave can compare the global variable to the value in the field to confirm that the value was really changed. (A user can edit a field, then change their mind and modify it back to the original value and this will still trip onObjectSave.)

                       And at that point, you can pop up a message asking for confirmation and since the value is there in that global variable, you can easily revert the value.

                       Example: Say you set this up on a field named Invoice::Date. You put Invoice::Date as the script parameter to the OnObjectEnter trigger you set on the Invoice::Date field. THe script has just one step: Set Variable [$$PrevValue ; Value: Get ( ScriptParameter ) ]

                       This successfully captures the original value even when the field is formatted with a pop up menu. You only need one such global variable for all your fields on your layout as you process the possible change on any one field before you can enter a different field to edit it.

                       And you can generalize the OnObjectSave performed script to work with many different fields by comparing $$PrevValue to Get ( ActiveFieldContents )

                  • 6. Re: Go to Field using a calculation
                    Matty_1

                         As far as I can tell this is exactly what I'm doing with a  few exceptions ... First I get Get (ActiveFieldContents) in my set variable for the OnObjectEnter. and the other difference is I use OnObjectExit for the script I posted above.

                         Not sure what the difference between OnBovjectSave and Exit are.

                    • 7. Re: Go to Field using a calculation
                      philmodjunk

                           OnObjectSave will only be tripped if the value of the field has been modified in some way. OnObjectExit will be tripped even if you just click in the field and then click somewhere else. It may make no difference in your script.

                           Capturing the value with Set Variable, OnObjectEnter, will not work for fields with a pop up menu format, the value selection is processed before the script trigger performs the script and thus the active field contents will be the modified value rather than the original.

                      • 8. Re: Go to Field using a calculation
                        Matty_1

                             So the only difference is that Get ( ScriptParameter ) gets the content before get active field would?

                        • 9. Re: Go to Field using a calculation
                          Matty_1

                               Is there any way for me to keep a commit record in my script and still use tabbing?

                          • 10. Re: Go to Field using a calculation
                            LaRetta_1

                                 I have been unable to follow this script thread because I'm currently over-extended but I saw this phrase and must respond:

                                 Phil said, "Capturing the value with Set Variable, OnObjectEnter, will not work for fields with a pop up menu format, the value selection is processed before the script trigger performs the script and thus the active field contents will be the modified value rather than the original."

                                 Actually you can capture starting value in pop-up menu using OnObjectEnter.  You can load Let() variables!  

                                 Create script with a single step:  Exit Script [  ]

                                 ... then attach it to OnObjectEnter and put this as its script parameter:

                                 Let ( $$prior = Get ( ActiveFieldContents ) ; "" )

                                 You've now loaded its prior value and it can be used in a secondary script OnObjectModify to return the field to its prior value.   I keep a single-step Exit Script[] script just to use in this way.  It works as well on radio button and checkbox which both also 'normally' do not respond to OnObjectEnter.  So no, you can't set a variable with starting value but you can load a Let() variable.

                            • 11. Re: Go to Field using a calculation
                              Matty_1

                                   Wonderful, all great suggestions!  As I previously mentioned, how can I set myself up to have the data committed but still use tabbing?  If I don't commit the data after the user leaves the field and changes their mind on another field I don't want the entire thing to revert, only what was just canceled.

                              • 12. Re: Go to Field using a calculation
                                philmodjunk

                                     Commit the record, then put the cursor into the desired field with, (sorry), go to object. (Yeah, back to naming all the fields with matching object names.)

                                     You might consider an alternative approach: Use a set of global fields for entering/editing the data. Then a "save" button performs a script that updates the actual fields by using set field steps to move the data into the corresponding non-global fields.

                                • 13. Re: Go to Field using a calculation
                                  LaRetta_1

                                       Consider too that the script step Go To Previous Field does so according to the tab order and NOT according to where the cursor was prior.

                                       Therefore (untested since I'm on ipad in the mountains presently), it might be reasonable to expect that if you use the following:

                                       Go To Previous Field
                                       Go To Next Field

                                       ... you would end up where you were.  

                                  • 14. Re: Go to Field using a calculation
                                    philmodjunk

                                         Hi LaRetta, excellent idea, but by one quickie test here, it does not work. It actually puts you on the first field in the tab order.

                                         Commit record---> nothing has the focus, same as clicking the layout background
                                         Go to Previous ---> puts you on the last record in the tab order
                                         Go to next-->cycles you to the first record in the tab order.

                                    1 2 3 Previous Next