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.

ExecuteSQL - does it not follow portal filtering processes?

Featured Replies

Hi there

 

I'm quite new to FM and come from a SQL background, and am struggling here a bit...

 

I'm looking to run an ExcuteSQL command on a table which contains values for many customers.  Each set of values per customer on my source table has their customer ID and in turn this is related to the customer table.

 

I need to create a portal on the customer layout, based on the value table, using ExecuteSQL.  

 

I need to use ExecuteSQL to enable dynamic variables based on user input which will filter the results in the portal, producing average, maximum, minimum and so on.

 

ExecuteSQL ("
 
Select max(FTE) from Values where Type =?";"";"";GlobalFields::GF_Types
 
)
 
The query above reviews ALL customer data on the value table and instead of the maximum value for the customer who's record is currently open, I get the maximum value for the table overall, which is no good to me.
 
How do I filter this to behave like the portals usually do, displaying information relating only to the parent record being viewed?
 
Any help gratefully received.
 
Thanks
 

You need a second WHERE clause on the foreign key in values that represents the parent

ExecuteSQL ("
 
Select max(FTE) from Values where CustomerID=? and EmployeeType =?";"";"";practiceNames::customereid ; GlobalFields::GF_Types )
 
)
 
 
You have to pass both variables into the eSQL function.. It gives you a syntax error "?" because it does not understand CustomerID=PracticeNames::customerID.
 
You should also check to see if "values" is an SQL reserved word.
 
PS ExecuteSQL operates outside the normal boundaries of FM and is context independent. Therefore it does not honor interface (portals, filtered/sorted or not) or relationship graph devices (filtered/sorted relationships )
  • Author

Kris, 

 

Thanks for the help on this, works like a dream :)

Wim gets some credit too!

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.