If you have a layout_field that is formatted with a checkbox, radio button, etc. control style and accidentally drag and drop text on in, you can wind up with values in the field that you can NOT see.
What do we think about this as an auto-enter calc to match the valueList and optionally the number of allowed valueListItems ?
Let (
[
~value_list = @valueListNameFromID ( "" ; 102 ) ;
~value_list_items = ValueListItems ( "" ; ~value_list ) ;
~filterValues = FilterValues ( Self ; ~value_list_items ) ;
~number_of_choices_allowed = 2 ;
~filterValues.allowed = RightValues ( ~filterValues ; ~number_of_choices_allowed ) ;~filterValues.allowed.length = Length ( ~filterValues.allowed ) ;
~filterValues.allowed.trimmed = Left ( ~filterValues.allowed ; ~filterValues.allowed.length - 1 ) ;
~result = ~filterValues.allowed.trimmed
] ;
~filterValues.allowed.trimmed
)
/////////////////
CF: @valueListNameFromID ( valueList.ID )
Let (
[
~the_ValueListIDs.padded = ¶ & ValueListIDs ( "" ) & ¶ ;
~a_ValueListID.padded = ¶ & valueList.ID & ¶ ;
~position = Position ( ~the_ValueListIDs.padded ; ~a_ValueListID.padded ; 1 ; 1 ) ;
~list.padded.left = Left ( ~the_ValueListIDs.padded ; ~position ) ;
~index = ValueCount ( ~list.padded.left ) ;
~a_valueListName = GetValue ( ValueListNames ( "" ) ; ~index ) ;
~result = ~a_valueListName
] ;
~result
)
/////////////////
Here is some background reading:
FileMaker Drag and Drop: Handling Script Triggers and Validation
FileMaker developers work to control a record's life cycle, but FileMaker Drag and Drop can subvert that entire process. We look at a possible solution.
Est. reading time: 6 minutes
// v2
// merged the CF into the code
// added UniqueValues
// moved config lines to the top
// added test data "TV¶TV"
Let (
[
~a_ValueListID = 102 ;
~number_of_choices_allowed = 2 ;
~a_ValueListID.padded = ¶ & ~a_ValueListID & ¶ ;
~the_ValueListIDs.padded = ¶ & ValueListIDs ( "" ) & ¶ ;
~position = Position ( ~the_ValueListIDs.padded ; ~a_ValueListID.padded ; 1 ; 1 ) ;
~list.padded.left = Left ( ~the_ValueListIDs.padded ; ~position ) ;
~index = ValueCount ( ~list.padded.left ) ;
~a_valueListName = GetValue ( ValueListNames ( "" ) ; ~index ) ;
~value_list_items = ValueListItems ( "" ; ~a_valueListName ) ;
~filterValues = FilterValues ( "TV¶TV" ; ~value_list_items ) ; // for testing where Self does not work
// ~filterValues = FilterValues ( Self ; ~value_list_items ) ; // Self works in an auto-enter calc
~filterValues.unique = UniqueValues ( ~filterValues ) ;
~filterValues.allowed = RightValues ( ~filterValues.unique ; ~number_of_choices_allowed ) ;
~filterValues.allowed.length = Length ( ~filterValues.allowed ) ;
~filterValues.allowed.trimmed = Left ( ~filterValues.allowed ; ~filterValues.allowed.length - 1 ) ;
~result = ~filterValues.allowed.trimmed
] ;
~result
)
2 Likes
Would be better if the Auto-enter fixed the case of the values to match the value list items.
That would make a good v3!
Issue with v2 shown below