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.

Globals and if/else statements

Featured Replies

Hi

Could someone tell me if this is possible - I have a global field (aelist) in my database with several user names, what I want to do is check the current username against a name in 'aelist' to see if there is a match. The code I though it would be is (doesn't seem to work) - thanks. Also, why can't I post any text after the code below in this forum?

[FMP-if:aelist.cn.{currentusername}]Hit[FMP-Else]Miss[/FMP-if]

Hi, mindtpi99! Umm... I may be wrong (correct me, folks!) but isn't it [FMP-ClientUserName] for web users? Also, I'm only a semipro-once-in-a-while FileMaker Web developer so I get rusty, but here's my guess at what your tag should be...

[FMP-if: field:aelist .cn. {FMP-ClientUserName}]Hit[FMP-Else]MIss[/FMP-if]

Sorry -- can't help w/the code problem since I don't like to use it, but I don't think others have had trouble. If you are manually typing in the "code" command, maybe you need to close the tag? I almost always use the QUICK REPLY but I just checked the normal reply area and it has a little auto-thing that puts the tags up for you (both opening and closing code tags) and maybe you're closing tag fell off? I dunno.

--ST

Mindtpi99,

Why are you using a global field that has all the user names in it? Is it a repeating field? Otherwise how would you store diffrent user names when a global is universal throughout the entire database? Also, try not to use globals while web-publishing. It can mess everything up.

Justin Grewe

Hi,

"try not to use globals while web-publishing" - good point Justin.

People developing FileMaker for client/server environments often use Globals for temporary storage. Bad move on the web as you don't know who else is going to submit at almost exactly the same time.

Store stuff in Tokens or cookies (FMPro cookies work reliably if they are set to expire at the end of the session).

Also the syntax for a field in the right side of an "If" should be:

[FMP-IF:fieldname.cn.Field.fieldname2]

or using a cookie:

[FMP-IF: FMP-COOKIE:userid.eq.Field.username]

FileMaker expects a field on the left side so you don't need to declare "Field", but expects text /number on the right so "Field" is needed. You don't need to bracket it, in fact I think that doesn't work. Like most PMP stuff it doesn't appear to be case sensitive.

regards, jeff

I believe that mindtpi99 keeps a list of users in a Global for validation purposes. If that is the case it should work well!

All the best.

Garry

Garry,

How would mindtpi99 keep multiple instances of users in one global? A global is not allowed to be a repeating field, right? And the global is universal with only one value at a time throughout the entire database, right? How else is this possible then Garry? If there is a way, I would really like to know.

Justin Grewe

My assumption is that it is a list of users allowed certain access.

By using "contains" as the search criteria, a string of many words can be used.

For example:

"Allowed Users" Global Text { smith, jones, boots, green, bloggs }

The Form would have:

<input type="hidden" name="-op" value="cn">

Enter User Name: <input type="text" name="Allowed Users" value="">

All the best.

Garry

Garry,

Thank you, this makes sense.

Justin Grewe

  • Author

Thanks for everyone's comments - Garry is quite correct in what I want to do.... The format for the conditional for what I wanted to do that seems to work is;

[FMP-IF:globalfieldname.cn.{clientusername}]Show this HTML Code[FMP-Else]Don't show it[/FMP-if]

cheers

howard

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

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.