Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 2967 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

Greets all:

I've read the FileMaker Help on this (http://www.filemaker.com/help/13/fmp/en/html/scripts_ref1.36.43.html) as well as some of the threads here and I just can't wrap my head around how to implement the Set Field by Name for a short script...assuming that's the correct command to use, of course. 

I've attached a screenshot of what I've done so far just so you can get an idea of what I want to do: For any field that has a On Object Enter script trigger attached, what I want to happen is that when a user clicks in that field it will toggle the result; if that field is empty the script will insert an "X" into the field; if it already has an "X", then it will clear it.  (As you can surmise, I'm using these as checkbox fields without having to assign the Control Style as a checkbox field.) 

You may be wondering about the ActiveModifierKey part: Because the script trigger will fire automatically when a user mouse clicks a field, I need a way to halt the script so if the user wants to change a found set's values from say, "X" to "empty", holding down the Option/Alt key will all him/her to manually clear the field then use the Records > Replace Field Contents command to clear the fields. (If you can think of a more elegant solution of doing this I'm all eyes!)

TIA for your help!

 

(...and yes, I know Dialog should be off in the Commit Records step.)

Screen Shot 2.png

Edited by WF7A
Clarification
Posted

Thanks for the link! I incorporated the script that was in the comments and have attached the file for anybody that's interested. Holding down the SHIFT key will halt the script trigger-fired script so you can enter/remove the value to allow for Replace Field Contents.

Toggle.fmp12

Posted

Great. That always shows you how to abstract a script so that it can function from any context given the correctly passed parameters.

Why did you opt for a text value rather than 1? I prefer my boolean fields to be 1 or 0 (or 1 and null).

Then, all you'd need is [Set Field by Name (myfield) ; not myfield )]

 

Posted (edited)

I'm sure it's my ignorance or incompetence showing, but because I wanted to have an "X" for a checkbox character instead of a non-intuitive "1" for end-users; looking at your very elegant calculation, I couldn't figure out how to make it work for a non-Boolean character. I tried fiddling around a little bit in the Inspector by setting the Data Formatting > Format > Boolean > Show Non-Zero to "X", but when in Find mode and clicking in the so-assigned field, a "1" would appear; that would stymie end-users.

Edited by WF7A
Posted
12 minutes ago, WF7A said:

looking at your very elegant calculation, I couldn't figure out how to make it work for a non-Boolean character

There is no elegant way to make it work for a non-Boolean value. However, you could make the field narrow enough so that the character "1" is not seen. Or format the text color to the color of the background. Or don't show the field as checkbox; show it formatted as Boolean and make it a button to toggle the value. Or don't show it at all, and use only  a button with conditionally formatted/hidden text.

Having status fields as Number fields with 0/1 (or empty/1) values has additional advantages - see: http://fmforums.com/topic/47570-set-a-field-based-on-portal-content/?do=findComment&comment=222189

Posted

Another trick is to use padding settings. Left 20 will push the 1 and then narrow the field.

This topic is 2967 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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