Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Script to make Global Variable from field value

Featured Replies

I'm working on a troublesome layout, which involves a layout to enter find criteria, and another to display the results. I want to display the search criteria in the results layout, and have been advised that setting a Global Variable to the value of the search field is the best way. This is in a script triggered on leaving the field.

However, I cannot for the life of me find a script action that "gets" the current field value and allows me to include it in a calculation that stores the result in a global variable. (Not without altering the contents of the field, anyway.)

Any help would be great.

Thanks.

I want to display the search criteria in the results layout, and have been advised that setting a Global Variable to the value of the search field is the best way.

We don't have the context in which this takes place. How exactly are users entering the search criteria? If they use global fields (and why would they not use global fields?), then you can display those global fields directly, without transferring their values to variables.

In any case,

Set Variable [ $$yourVariable ; Value: YourTable::SearchField ]

would do what you have asked for. However, if the criteria are entered in Find mode (i.e. not into a global field), then the variable must also be set while still in Find mode.

  • Author

Thanks, I couldn't find "Set Variable". (I seem to be completely blind when it comes to finding these actions in the list at the side...!!)

Without wishing to get sidetracked by global fields -- My understanding of a global field is a field that carries the same value for all records. So if I used that as my search criteria, wouldn't I get every record as the result?

As things stands, the search fields are drop down boxes of Value Lists. So far, it all seems to be working well. (Except displaying the results, but that's for another day.)

You wouldn't actually search IN the global, you'd just use it to specify the criteria. E.g. you have a global called FindThisName, and then use it in a script like this to perform a search on your (non-global) Name field:

Enter Find Mode

  Set Field( Name ; FindThisName )

Perform Find

  • Author

I'm not sure that I see the advantage of a Global field rather than a global variable.

As it stands, I have a list of items in a Value List, (which relate to a sub-table of "attributes" that each record can hold zero or more of). The user selects an attribute from a drop-down list, and the search shows all the records that contain that attribute. The Results layout shows a list of the records that hold that attribute**, and I have the name of the attribute at the top of the list, so you know what you've searched for.

If I did this using Global fields, I would have to select a value from the drop-down list, then set the global field to the selected value, and then set the field I want to search to the value in the Global Field. Whereas at the moment, I just select the value from the list in the relevant field and just use a Global Variable to pass the name of the search. Isn't that quicker?

** except I'm having trouble producing a list, but that's another story.

The advantage of a global field (in this context) is that users can enter data directly into a global field AND they can do so both in Browse or Find mode AND there is no danger of modifying actual data while entering search criteria.

If I did this using Global fields, I would have to select a value from the drop-down list, then set the global field to the selected value, and then set the field I want to search to the value in the Global Field.

No, not exactly: you would select a value from the drop-down list directly into the global field.

  • Author

A ha!

Right, now I understand.

Thanks.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.