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.

"Universal" Constrain --- Syntax

Featured Replies

Greets, all:

I'm trying to set up a part of a script where it constrains on a Primary Key to isolate a record, irrespective of its table, and I'm stuck on the syntax.

The set-up:

Variable: $_TableName = Get (LayoutTableName)

The Primary Key: They all have the same naming convention in all the tables: _kplt_TableNameID" . The value inside every Primary Key is set by  Get ( UUID ).

 

Where I'm getting hung up is the Set Field syntax; the script (so far) goes like this:

 

Enter Find Mode [Pause: Off]

Set Field [ Evaluate ( $_TableName & "::" & "_kplt__" & $_Tablename & "ID" ) ;  ????? ]

Set Error Capture [ON]

Constrain Found Set [  ]

 

What do I use for the ??????  Also, is there a more elegant way of doing the same thing by using the Find Matching Records command?

 

As always, thanks in advance for your help!

 

14 minutes ago, WF7A said:

I'm trying to set up a part of a script where it constrains on a Primary Key to isolate a record

Do you mean you want to isolate the current record, so that it becomes the only record in the found set?

  • Author

Yup.

First, have a look at this classic:
https://fmforums.com/topic/97497-constrain-to-current-record/?do=findComment&comment=443142

 

To do it the way you have started, you would need something like:

Set Variable [ $fieldName; Value:Get ( LayoutTableName ) & "::" & "_kplt__" & Get ( LayoutTableName ) & "ID" ] 
Set Variable [ $id; Value:GetField ( $fieldName ) ]
Enter Find Mode [ ]
Set Field By Name [ $fieldName; $id ]
Perform Find []

Note that the Evaluate() function is not needed for this. Also there is very little point in setting a variable to one of the Get() functions: most, if not all of them are just that: variables.

 

1 hour ago, WF7A said:

is there a more elegant way of doing the same thing by using the Find Matching Records command?

I don't think so, because Find Matching Records[] does not allow the use of a calculated field name.

  • Author

Ah! Thanks.

Just for the sake of (an) argument, say I wanted to constrain to a specific field but its contents could be anything (not empty); what would I replace "ID" with?

The whole idea is predicated on you using a consistent naming convention so that all your primary keys take the form:

"_kplt__" & Get ( LayoutTableName ) & "ID"

I wouldn't think you'd use that convention for every field in the table, that would be weird. So you wouldn't replace "ID" -- you'd completely replace that whole string with whatever field name you want to use. 

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.