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.

Script trigger not working for pop-up menus and check boxes

Featured Replies

I'm designing a contact-management layout. Each record in this database can be either personal or corporate, and there's a checkbox on the layout so the user can choose one or the other.

There are fields in each record for both personal and corporate info. Ideally I would use conditional formatting to hide irrelevant fields (e.g., the company name in a personal record), but this layout needs to work in IWP. So I've laid out the layout with two subsections, "personal" and "corporate." But I still want to prevent users from entering/editing data in irrelevant fields, so I've set up an OnObjectEnter script trigger that immediately commits the record if the user tries to edit an irrelevant field (hat tip: raybaudi).

Problem: This only seems to work on text fields. Pop-up menus (e.g., HisTitle and HerTitle) and check boxes continue to function, as if the script trigger weren't there! (And yes, those fields do have little golden asterisks when I look in "Edit Layout.")

What gives? Am I doing something wrong?

Thanks in advance!

Edited by Guest
Added check boxes. :(

Hi

1) pass the value of the field itself as Script Parameter

2) Add this step to your script:

Set Field [ <--no field name here--> ; Get( ScriptParameter ) ]

I think the problem is that when clicking a pop-up or check box you not actually entering the field.

A better option may be to use completely different layouts for each. The use a OnRecordLoad script to switch between them automatically.

  • Author

But wouldn't that switch to a second layout mean a significant delay on the user's end? (Remember, I've got a bunch of people - including my boss! - who'll be using IWP.)

  • Author

@raybaudi:

I've been using a global script, and when I try to add that line to it, the script builder doesn't allow me to insert a semicolon without specifying a field name. That is, instead of

Set Field [ <--no field name here--> ; Get( ScriptParameter ) ]

I end up with

Set Field [ Get( ScriptParameter ) ]

Is that okay? It doesn't look right.

  • Author

Update: The "enriched" scripts work great, as long as I'm in FilemMaker. But in IWP I get the following error:

Data Entry Error:

Your attempt to save changes to the current record or request failed because of the following:

Invalid numeric value in field "Comp_Org_Flag."

"Comp_Org_Flag" is the field used to flag a record as corporate.

Ack!

I end up with

Set Field [ Get( ScriptParameter ) ]

Is that okay? It doesn't look right.

But it is !

We do not specify the field name because so the "Set field" will act on the active field ( and clicking a field makes it active ).

So now go and try it.

Update: The "enriched" scripts work great, as long as I'm in FilemMaker. But in IWP I get the following error...

Which value have you passed as script parameter ?

  • Author

The existing value in the given field. (That is, if the user clicked in the "TitleF" field, I specified "TitleF" as the ScriptParameter.)

Here's the full script, as it appears in the Edit Script window:

If [People::Comp_Org_Flag = 1]

Set Field [ Get ( ScriptParameter )]

Commit Records/Requests [skip data entry validation; No dialog]

End if

Thanks for all your help!

The script seems correct.

If it's not working in IWP and FM gives you that error message, I **think** that you have a wrong validation for the field: Comp_Org_Flag.

Which is it ?

  • 2 weeks later...
  • Author

Sorry for the prolonged absence! There definitely are validation issues going on - with other fields, too - and I haven't been able to work them out yet. (I'm the admin of a non-profit, and I was working on this FMP project during a rare quiet period.)

In the meantime, thanks again for your help with the script! It continues to amaze me how many people make time to help their fellow users.

  • Author

I've finally gotten back to this project. Three updates, including a follow-up script trigger question:

~ The strange validation behavior has gone away! My Mac had been getting flaky in other ways, and I've restarted it a couple of times since last we met; I assume that's what's fixed FMP, too. (Makes me wonder if I should find another computer to host the database once it's done...)

~ I've discovered that an IWP user must commit a record immediately after flagging/unflagging a record as corporate - otherwise, these scripts don't get triggered correctly. I guess I can set up another script trigger to commit the record automatically.

~ I see that this trick only works on fields that contain text. The script doesn't prevent users from clicking on a couple of checkboxes (e.g., one that flags/unflags a personal record as that of a widow) and changing their fields' values from 0 to 1 and back again. At first FileMaker intimated that the script parameter had to be text-only. But changing people::widow from a number field to a text field didn't help! How do I lock down these check boxes?

Script triggers behave differently in IWP. Significantly. You may need to reconsider the implementation.

From the FMP Help:

In Instant Web Publishing and Custom Web Publishing, script triggers can only be activated by a script and not by direct user interaction. For example, if a user tabs into a field that has an OnObjectEnter script trigger, the trigger will not activate. If a script step causes focus to move into that field, the script trigger will activate.
  • Author

@Vaughan: Problem was, the layout was misbehaving even when used in FileMaker proper - not just in IWP. (And I always have the script builder grey out IWP-incompatible steps when I'm working on stuff like this.)

However, I think I've figured things out! I forgot that the various check boxes on this layout are actually scripted buttons. The script toggles a boolean value back and forth, and allows me to put just one checkbox on a layout, instead of two - a technique Comment showed me years ago.

The solution: I've set up the buttons to run actual scripts. The script for the "corporate flag" toggles the value and immediately commits the record (thus fixing the IWP delayed-commit problem). The scripts for the "widow" and "uses her own surname" checkboxes now check on the status of the "corporate flag," then either commit the record (if corporate) or toggle the boolean value.

Thanks again to everyone.

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.