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.

Trying to Create a Script that Branches based on which of 3 buttons are selected.

Featured Replies

Hi all,

I have three buttons in a popover. Each button exports records as excel with the only difference among the three buttons is "which" records are to be exported:

  • Current Record (Always just one record)
  • Found Records (Always a varied quantity)
  • All Records (All records within the table)

Initially, I had three separate scripts (one for each button) and they all worked. Now, I want to consolidate these three scripts into one script.

I thought I could branch each of the three button's script steps by using each button's unique object name as the differentiator.

WHAT I DID

  • I created a variable to contain the selected "objects" unique name using Get(LayoutActiveObjectName).
  • I created branching logic in the script utilizing IF/ELSE IF/END IF
  • I created temporary dialog window to show me the results for "debugging" simplicity.

MY RESULT

In Script Debugger, I watch as the branching is completely ignored: it just goes right on pass the branching I put in place. 

MY RESEACH

It appears others have wanted the ability to pass a selected button's object name into a script and they approached it in a similar manner as I did: but it appears that "clicking" on a button does not qualify in FileMaker as "activating" the object, and therefore never returning the object's name.

MY HUNCH

Using Get(LayoutActiveObjectName) is not the right "tool" to obtaining the name of the selected button.

IMPORTANT NOTE

I am already using the "Optional Script Parameter" by using JSON to pass multiple parameters to the script - so I do not know if I can "add" the selected object's name in the JSON "bundle" I already have.

QUESTIONS

  1. Can Get(LayoutActiveObjectName be used in this situation?
  2. Am I implementing the Get(LayoutActiveObjectName incorrectly?
  3. Can I add the name of my button objects to the existing JSON info bundle that I have in the Optional Script Parameter?
  4. What method/technique should I be using to accomplish this branching that I need?

SCREENSHOTS ATTACHED

  • 01__3_buttons_in_popover.png
  • 02__set_variable_scrit_step.png
  • 03__relevant_script_steps_showing_branching.png

Any help appreciated - thanks.

01__3_buttons_in_popover.png

02__set_variable_scrit_step.png

03__relevant_script_steps_showing_branching.png

Edited by dmontano
grammer

36 minutes ago, dmontano said:

I thought I could branch each of the three button's script steps by using each button's unique object name as the differentiator.

That's not going to work.

36 minutes ago, dmontano said:

it appears that "clicking" on a button does not qualify in FileMaker as "activating" the object,

Exactly. A button activates only by tabbing into it.

36 minutes ago, dmontano said:

Using Get(LayoutActiveObjectName) is not the right "tool" to obtaining the name of the selected button.

Again, your hunch is correct.

36 minutes ago, dmontano said:

I am already using the "Optional Script Parameter" by using JSON to pass multiple parameters to the script - so I do not know if I can "add" the selected object's name in the JSON "bundle" I already have.

You don't need to add the selected button's object name to the script parameter. In fact, the buttons do not need to have object names at all (at least not for this). You only need to add a recognizable value to the script parameter of each button. It could be as simple as 1, 2 and 3 or perhaps something more explicit - say "current", "found" and "all". Then extract this value from the script parameter and use it to branch your script.

 

Edited by comment

  • Author

Hi Comment

Following your guidance, I got this to work - thank you!

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.