Skip 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.

Can I change a value list on a field via scipting?

Featured Replies

Hi,

I am migrating from FMP3 to FMP7 and I love the new features. There is one thing I am trying to do that is making my noggin' hurt and I would appreciate any suggestions for a way to do this.

I have a form which I want to be multifunction. A button at the top is clicked to toggle the form between 'Ordering Mode' to 'Stock Control Mode'. When the button is clicked, all the button labels etc on the layout change to reflect the new mode and so on.

However, if the user is in 'Ordering Mode' they need a drop down list of our suppliers (which would point at a global field) so they can select which one they want to work with. But if they are in 'Stock Control Mode', they need a drop down list of Stock Control Actions (eg 'add to stock', 'remove from stock').

Is it possible somehow to assign seperate value lists to a single field, or change the field on the form when they select a new mode, or use a relationship somehow to affect the displayed value list?

Any help would be greatly appreciated as I am running low on Ibuprofen grin.gif

Codeus

It seems to me that the easiest thing would be to have 2 layouts. Then all your script has to do is switch between the layouts.

  • Author

I found a solution to this that works OK.

In my main table I added a calculation field with a constant '1' in it for all records to use as a link.

I created a new linked table called 'VariableValueList' and added three fields and a single record: -

number.RelatonshipLink = 1

text.ValueListHolder = ""

text.ReturnValue = ""

I then dropped the 'text.ReturnValue' field in to my layout and formatted it as a pop up-list, using values from field, 'VariableValueList::text.ValueListHolder'.

I then created a script which dumped the correct value list in to the ValueListHolder field using the ValueListItems control with an IF statement: -

Set Field: ValueListHolder;

If (

Mode = "ordering";

ValueListItems("<database name>";"<supplierlistname>");

ValueListItems("<database name>";"<stockcontrollistname>")

)

Upon running the script the ValueListHolder field is populated with the correct list, once you select an item from the drop down box, that value is placed in the 'ReturnValue' field ready for use.

I hope my solution helps others and I would still like to hear any other suggestions for doing this kind of thing.

Codeus

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.