5 Replies Latest reply on May 29, 2012 11:18 AM by philmodjunk

    Accessing a Fields' Content

    DavidEnns

      Title

      Accessing a Fields' Content

      Post

      I want to access a fields' contents with a script attached to it without having to specifically name said field within the script. For instance with Get ( ActiveFieldContents ). How can I do this when, technically, the field isn't active. Its only highlighted because of the script attached to it. 

        • 1. Re: Accessing a Fields' Content
          philmodjunk

          Use the GetFIeld function. You'll need to use a variable or a field to specify the name of the table occurrence and field as parameters. This is the companion to the set field by Name script step.

          • 2. Re: Accessing a Fields' Content
            DavidEnns

            Update: might help things better.

             I have 15 fields containing different gps coordinates. I want to be able to attach the same script to each field that accesses the fields' content on press, store in a variable and load in google maps. I don't want to name each field within said script. 

            Set Variable [ $$Coordinates; Value: Get ( ActiveFieldContents )] works when the field has focus or is tabbed into and I set the script trigger to onObjectEnter. Doesn't work when I use button setup and attach a script to a field...which is what I'm really looking for.

            • 3. Re: Accessing a Fields' Content
              philmodjunk

              No, but you can pass the name of the field as the script parameter.

              Set up your fields as buttons. Select the Perform script option and use GetFieldName ( Yourtable::yourField ) in the optional script parameter box.

              You'd use this function instead of "Yourtable::YourField" so that your scripts will continue to work even if you should open Manage | database and change the name of one of these fields.

              Then, inside the script, you can use getField ( get (ScriptParameter ) ) to access the contents of the field that is named in the script parameter.

              Alternatively, you can choose not to use button setup and instead use the OnObjectEnter script trigger. In this case, clicking the field makes it the active field and then get ( ActiveFieldContents ) will work You can use commit record, got to field or go to object to move the cursor back out of the field and the user will never know they entered it, they simply clicked it.

              • 4. Re: Accessing a Fields' Content
                WillPeart

                 

                I found this very helpful:

                "Alternatively, you can choose not to use button setup and instead use the OnObjectEnter script trigger. In this case, clicking the field makes it the active field and then get ( ActiveFieldContents ) will work You can use commit record, got to field or go to object to move the cursor back out of the field and the user will never know they entered it, they simply clicked it."

                I am using 'OnObjectEnter' to run scripts that use the contents of the field clicked. One thing would improve this setup - is there a way to make the cursor change into a hand when it is hovering over the field as it would if the field were setup as a button?

                (note, if the field is setup like a button and runs the same script as i am running using the OnObjectEnter script trigger, the Get(activefieldcontents) function doesn't work)

                • 5. Re: Accessing a Fields' Content
                  philmodjunk

                  The only way to get the "hand" cursor is if it is hovering over a button. Your script can use go to field to put the cursor into the field, but I'd just pass the table::field names as a script parameter as I described earlier in that case.

                  The one situation where this won't work is if you want the mouse click to select a specific part of the data in the field. I've set up calculation fields, for example, where clicking a word or row of text in the field performs a script that first extracts the clicked word or line of text from the field and then uses it to control what results are produced by the script. In those cases, I have to do without the hand cursor unless I put invisible buttons over different parts of the field--something that doesn't always work anyway.