# How to know what field is clicked on when it's treated like a button

**URL:** <https://the.fmsoup.org/t/how-to-know-what-field-is-clicked-on-when-its-treated-like-a-button/2059>\
**Category:** Questions\
**Tags:** scripting, fields\
**Created:** [April 23, 2021, 10:08pm UTC](https://the.fmsoup.org/t/how-to-know-what-field-is-clicked-on-when-its-treated-like-a-button/2059 "2021-04-23T22:08:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JasonMark](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@JasonMark](https://the.fmsoup.org/u/JasonMark)\
**Post date:** [April 23, 2021, 10:08pm UTC](https://the.fmsoup.org/t/how-to-know-what-field-is-clicked-on-when-its-treated-like-a-button/2059/1 "2021-04-23T22:08:52Z")

</div>

I have a number of fields that I want to change when I click on them, is there some way that Filemaker can be aware of what field is clicked on other than naming them?

So I have Table::Field1 and Table::Field2

Right now I have a script on Field1 which says "Perform my script and pass in Table::Field1" and then the same script on Field2, but I let it know it's Field2.

I tried "get(ActiveField)" and it doesn't grab the field name/path since it's not selected.

Is there some way around this I'm missing? the only two ways I've figured out to do it are pass in the script parameter, or to manually "name" each field it's path...

---

<div class="post-metadata">

**Author:** ![Vincent\_L](https://avatars.discourse-cdn.com/v4/letter/v/b5a626/32.png) [@Vincent\_L](https://the.fmsoup.org/u/Vincent_L)\
**Post date:** [April 23, 2021, 10:50pm UTC](https://the.fmsoup.org/t/how-to-know-what-field-is-clicked-on-when-its-treated-like-a-button/2059/2 "2021-04-23T22:50:02Z")

</div>

if your field are browse mode check (and editable, didn't tried on calc ones), you can put a script trigger OnObjectEnter on them and pass to the script get(actifivefieldname).

this has caveats, one of it is that he can be slow if field content is big

But I would go with script parameter.

What's your goal ? is it just to save a lot of mousing declaring the parameters on each button ?

if so, you could create one field, put the buttton on it with its param. Then you duplicate you field / buttons to the necessary nuber. Then you select all your field/buttons, and you copy that , then with something like clip manager, you get the xml code of your buttons, and you edit your code in and ide, and then paste bac thourgh clip manager.

But not sure you'll gain much time

---

<div class="post-metadata">

**Author:** ![JasonMark](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@JasonMark](https://the.fmsoup.org/u/JasonMark)\
**Post date:** [April 24, 2021, 12:20pm UTC](https://the.fmsoup.org/t/how-to-know-what-field-is-clicked-on-when-its-treated-like-a-button/2059/3 "2021-04-24T12:20:36Z")

</div>

OK thanks. Partially to save time clicking, but also make it more bulletproof if I need to change a field name or table name or something down the road.

---

<div class="post-metadata">

**Author:** ![JasonMark](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@JasonMark](https://the.fmsoup.org/u/JasonMark)\
**Post date:** [April 24, 2021, 12:49pm UTC](https://the.fmsoup.org/t/how-to-know-what-field-is-clicked-on-when-its-treated-like-a-button/2059/4 "2021-04-24T12:49:18Z")

</div>

> [@Vincent\_L](#):
>
> What's your goal ? is it just to save a lot of mousing declaring the parameters on each button ?

The other reason is I have the same action on multiple screens, using different joins. So on one screen it might be Students:DCF and on another it might be Tasks:Students:DCF. I want to just copy the field with all it's formatting intact and have it "just work", so as the layout gets tweaked I don't have to manually update all of them.

---

<div class="post-metadata">

**Author:** ![rivet](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/rivet/32/1727_2.png) [@rivet](https://the.fmsoup.org/u/rivet)\
**Post date:** [April 24, 2021, 4:32pm UTC](https://the.fmsoup.org/t/how-to-know-what-field-is-clicked-on-when-its-treated-like-a-button/2059/5 "2021-04-24T16:32:55Z")

</div>

using Vincent's

> OnObjectEnter on them and pass to the script get(actifivefieldname)

is the simplest way to dynamically get the field name, as for the table name, use the script step `Get ( LayoutTableName )`

Piecing together this and a previous post of yours I have attached a sample of what I believe you are trying to accomplish.

Adding a new field is down to two steps;

ON THE LAYOUT

1. clone field
2. change the placeholder text

[onObjectEnter-fieldToggle.zip](https://the.fmsoup.org/uploads/short-url/cVJlGnI6OcPcZ9LjmGGgQtPtzsQ.zip) (85.1 KB)

---

<div class="post-metadata">

**Author:** ![JasonMark](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@JasonMark](https://the.fmsoup.org/u/JasonMark)\
**Post date:** [April 24, 2021, 8:31pm UTC](https://the.fmsoup.org/t/how-to-know-what-field-is-clicked-on-when-its-treated-like-a-button/2059/6 "2021-04-24T20:31:30Z")

</div>

@Vincent_L @rivet Thank you! Super helpful. Very elegant.
