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.

The difference between a field Reference and a Litteral

Featured Replies

I've been working on a series of custom functions for building SQL queries. As I tailor these Custom Functions to meet many different situations and combine them in many different ways as well as making some recursive, I am running into situations where I can send a field reference and other times when I need to send a literal name of a field. What I mean by that is for instance is I am either sending ~SQLfield ( Table::field ) referencing the field or ~SQLfield ( "Table::field" ) using literal text.

If I send as a field reference such as ~SQLfield ( Table::field )
The following works 

Let ([

~field = GetValue ( Substitute ( GetFieldName ( ~fieldRef ); "::" ; "¶" ) ; 2 ) ;

~table = GetValue ( Substitute ( GetFieldName ( ~fieldRef ) ; "::" ; "¶" ) ; 1 ) ;
~table = ExecuteSQL (

"
SELECT DISTINCT BaseTableName FROM FileMaker_Tables

WHERE TableName = ?
"

;"";""; ~table
)

];

Quote ( ~table ) & "." & Quote ( ~field )

)

 

If I send as a field reference such as ~SQLfield ( "Table::field" )
The following works 

Let ([

~field = GetValue ( Substitute ( ~fieldRef ; "::" ; "¶" ) ; 2 ) ;

~table = GetValue ( Substitute ( ~fieldRef ; "::" ; "¶" ) ; 1 ) ;
~table = ExecuteSQL (

"
SELECT DISTINCT BaseTableName FROM FileMaker_Tables

WHERE TableName = ?
"

;"";""; ~table
)

];

Quote ( ~table ) & "." & Quote ( ~field )

)

 

The difference being in the use of GetFieldName ( ~fieldRef ) when sending a field reference which does not work when sending the field name as a litteral.

 

So my question is this.

Is there a way within the custom function to determine if the value being passed is a reference or a literal and adjusting accordingly so that passing either ~SQLfield ( Table::field ) or ~SQLfield ( "Table::field" ) could both work?

 

 

Edited by Ron Cates

Maybe. But maybe you'd be better off with separate functions.

  • Author

That's actually what I have done. I was just hoping there was a way so I could consolidate them.

  • Author

Bam! Racked my brain all day Friday trying to figure it out, came in this morning and there it is!

Thanks Wim :)

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.