AnsweredAssumed Answered

Passing a Field Name as a Parameter?

Question asked by BMyers on Jul 25, 2016
Latest reply on Jul 27, 2016 by BMyers

Quick version of my question:

 

I have a script attached to a button.  I want to use the same script for more than one field, so I’m trying to pass a parameter that represents a field name.  The goal of the script is to put a Boolean 0/1 in a field so it can be used as a checkbox.  I’m having trouble getting the script to recognize a field name in the parameter box.

 

Long version:

 

The goal is to create a simple Boolean checkbox, with the field holding the number 0 or 1.  The box itself is designed to be OSX style, with a empty white box icon for 0 and the OSX blue checkmark icon for 1.  Here’s how I’ve done it.  Click the button and the field toggles between 0 and 1 using a SetField script step:  If 0, then SetField to 1, Else If 1, SetField to 0.  Simple.

 

The button itself is a two-button button bar.  The first button is the empty box icon and the second button is the checkmark icon.  I used the Hide Object When option on the Inspector to force the empty box icon to hide if the field value is 1, and the checkbox button will hide if the field value is 0.  An interesting behavior of the button bar is that if one button is hidden the other buttons to the right will slide over to the left.  So if the field value is 1, then the empty box icon disappears and the checkbox icon appears and slides to the left.  Thus both icons seem to be located in the same position.

 

My app has several checkboxes.  This is for a table called Tasks so there are checkboxes to denote status or where the Task appears.  E.g., I have Boolean fields and checkboxes for “Done”, “Calendar” (meaning does it appear on the calendar), “Invoice” (meaning does it appear on an invoice), Critical Date, etc.

 

Clearly I can create separate scripts for each of the checkboxes.  That’s fine but I can’t leave well enough alone.  The goal now is to create a generalized script and use the script parameter feature to pass the target field. 

 

I can’t figure out how to do it.  I’ve tried using the Get (ScriptParameter) in the script without luck.  I’ve also tried setting a variable, and inserting the script parameter into the variable, then using the variable in the script. 

 

One final note: if there is a completely different (and better) method to do a Boolean checkbox with custom icons please let me know. 

 

Thanks

Outcomes