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.

Sort resultset after a newFindCommand

Featured Replies

  • Newbies

So the issue seems to be that I'm trying to sort on a field which is unstored. its pulled from another field if a value exists. its defintely pulling correctly as I can display the sort field in the search results.

heres the code that doesn't want to work:

$findCommand = $fm3->newFindCommand('Exhibitor Search');

$findCommand->addSortRule('ExhibitorSearchSort',1,FILEMAKER_SORT_ASCEND);

$result = $findCommand->execute();

So now I'm confused about what exactly filemaker has returned to me as $result. it is a multidimensional array? a resultset? can i use a standard php sort on this? somehow specifing the name of the field to sort by?

any help is appreciated and if i work it by some miracle i'll post so its here for someone else.

Edited by Guest

  • 2 weeks later...

Result is a result object or an error object depending on how your query went - you should take a look at the documentation.


<?php



$findCommand = $fm3->newFindCommand('Exhibitor Search');

$findCommand->addSortRule('ExhibitorSearchSort' ,1,FILEMAKER_SORT_ASCEND);

$result = $findCommand->execute();



/*After the find, check if it's an error. If it is, die with the message... obviously don't do this if this is a production environment*/

if( FileMaker::isError($result) ){

	echo $result->getCode().": ".$result->getMessage();

	die();

}



/* Retrieve array of record objects from the result object. These are already sorted by your ExhibitorSearchSort field */

$records = $result->getRecords();



/* Loop through the record object and manipulate using the commands you have available... Again look at the documentation. Most likely, you're after field values. */

foreach($records as $record){

	echo $record->getField("Name of Some field on the exhibitor search layout")."
";

}

Hope that's of some help - this is the quickest way to find the methods available and the return types for each fm function call: http://jonathanstark.com/filemaker_api_for_php_documentation.php

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.