# Auto-enter calc to make sure that drag and drop data is on the value list

**URL:** <https://the.fmsoup.org/t/auto-enter-calc-to-make-sure-that-drag-and-drop-data-is-on-the-value-list/3219>\
**Category:** Floating Topics\
**Created:** [November 24, 2022, 5:57pm UTC](https://the.fmsoup.org/t/auto-enter-calc-to-make-sure-that-drag-and-drop-data-is-on-the-value-list/3219 "2022-11-24T17:57:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonywhitelive](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/tonywhitelive/32/208_2.png) [@tonywhitelive](https://the.fmsoup.org/u/tonywhitelive)\
**Post date:** [November 24, 2022, 5:57pm UTC](https://the.fmsoup.org/t/auto-enter-calc-to-make-sure-that-drag-and-drop-data-is-on-the-value-list/3219/1 "2022-11-24T17:57:17Z")

</div>

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 Drag and Drop: Handling Script Triggers and Validation](https://www.proofgeist.com/blog/2018/01/08/filemaker-drag-drop-gotchas/)**
>
> 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.

---

<div class="post-metadata">

**Author:** ![tonywhitelive](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/tonywhitelive/32/208_2.png) [@tonywhitelive](https://the.fmsoup.org/u/tonywhitelive)\
**Post date:** [November 24, 2022, 7:12pm UTC](https://the.fmsoup.org/t/auto-enter-calc-to-make-sure-that-drag-and-drop-data-is-on-the-value-list/3219/2 "2022-11-24T19:12:05Z")

</div>

// 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  
)

---

<div class="post-metadata">

**Author:** ![tonywhitelive](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/tonywhitelive/32/208_2.png) [@tonywhitelive](https://the.fmsoup.org/u/tonywhitelive)\
**Post date:** [November 28, 2022, 9:45pm UTC](https://the.fmsoup.org/t/auto-enter-calc-to-make-sure-that-drag-and-drop-data-is-on-the-value-list/3219/3 "2022-11-28T21:45:54Z")

</div>

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

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/8/8d0a119dd9de3a9c7d2c11ce8517e49c469a47dc.png)
