Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Conditional based on PatternCount for WHOLE (not part of) numbers

Featured Replies

I elaborated a bit on this technique, more specifically the showing/hiding of things in portal rows based on conditionals.

I wanted to show or hide a "delete portal row" button in a QUE_ANS portal on a QUE layout using this conditional statement

PatternCount ( QUE::Emps ; QUE_ANS::_Emp_IDfk ) > 0

QUE::Emps is a multi-line field holding Employee IDs.
QUE_ANS is a portal on the QUE layout, based on QUE::__Question_IDpk = ANS::_Question_IDfk.
QUE_ANS::_Emp_IDfk is a single-line field holding an Employee ID.

My challenge is to SHOW the "delete portal row" button on a row in the QUE_ANS portal in case the QUE::Emps does NOT contain the QUE_ANS::_Emp_IDfk value.
I soon found out that PatternCount has its flaws: the conditional statement above will evaluate as TRUE if QUE::Emps holds for example "99" and QUE_ANS::Emp_IDfk is "199", even if those values are not equal.

There seems to be no xCount function for an EXACT match of numbers (or words).
The functions "ValueCount" or "WordCount" are no use, as they take 1 parameter only, they count things, they don't search.
The function "Exact" compares ALL of QUE::EMPS with QUE_ANS::Emp_IDfk, not a single line, so no use either.

Google to the rescue. I changed my conditional to:

PatternCount ( "¶" & QUE::Emps & "¶" ; "¶" & QUE_ANS::_Emp_IDfk & "¶" ) > 0

Pre- and post-pending both base and search string in the PatternCount function with a paragraph character seems to do the trick (as the search string must now be a whole line). Can anyone confirm? Or any better techniques without the use of Custom Functions (no FMP Advanced here)?

Edited by Roeland De Windt

Have a look at the FilterValues() function.

  • Author

Duh! Changed my conditional to:

ValueCount ( FilterValues ( QUE::Emps ; QUE_ANS::_Emp_IDfk ) )

Seems to work! No pre- or post-pending needed. A lot cleaner.

Thanks again, comments

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.