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.

Search script and ExecuteSQL

Featured Replies

Hi all, new user on the block :)

Anyhow, I want to be able to search a table from another table. I have tried using ExecuteSQL, but I seem to not be able to make it so I can for an example type "89547" instead off "895476", using the wildcard %.It only returns ?.

In the example file I attached I think I have been able to explain it more clearly. It has 1 000 randomly generated data to test on. It does not however contain any scripts.

If anyone could help me get on track I would be very grateful :=)

Regards

JohanA

Example.fmp12

Edited by JohanA

It seems that LIKE doesn't work on number fields - when I changed to Text for Prod_number, this worked:

Let([
query = "select\"Prod_Name\"
	FROM Products
	WHERE Prod_Number LIKE ?";

result = ExecuteSQL( query ; "" ; ""; "45%")
];
result
)

 

  • Author

Huge thanks webko, was going nuts on why it did not work :)

Now I have to figure out how to fill the portal, on the video I watched ge used the SetKey if I arent misstaken.

  • Author

Do anyone have a clue on how to output the result from a ExecuteSQL to a portal?
When I tried Set Field and have multiply rows of data it got put into one field :(
 

If you set the output from the ExecuteSQL (provided that it is just one field in the query) to a global field you can then use that global field as the 'left side' of a relationship to the table you want to show in the portal.

Looking at the query earlier in the thread, you'd want to return the product ID then, not the product name to avoid ambiguity in the relationship.

Another technique for this is "virtual list", do a search on the forum here and you'll find plenty of examples.

  • Author

I am having trouble showing the result in the portal. I am using Set Field to set the results in. It's a global field and the portal is showing that field and another. The problem is if I get many rows of data, it all gets put in one line. It just shows the first line, all other lines is there but I have to click in the portal for them to show.

Any ideas on how to make it show on seperate rows?

The Set Field script step looks like this, the variable the data is in is named "te": Set Field [Order::keyh_PORTALFILTER; $$te & ¶]

You're missing the part where you use the global field where you've set the result as the key to a relationship to the products table.  The portal will only show fields from that products table, the global results field is not in the portal (and does not even have to be on the layout)

  • Author

After much fiddeling around I managed to get it to work :)
I must have been blind, you sad " The portal will only show fields from that products table " , but stubborn as I was I added the global result field to the portal, which did not work at all :P
Anyhow, huge thanks. Now I can move on and get this solution working.

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.