dloughlin

Sorting the records returned by newPerformScriptCommand

Discussion created by dloughlin on Sep 3, 2012
Latest reply on Sep 5, 2012 by TimDietrich

I need to sort the reulting set of records returned as the result of a

newPerformScriptCommand

 

Some of the PHP code is as follows:

 

}else{

 

$records = $find_result->getRecords ();

 

I then get access fields with the $records object using

 

$record ->getField

 

 

It is this $records that I want to be able to sort by some of the fields within it.

 

It would seem that the obvious thing to do would be to sort the records within the script, but the fieldnames that I would want to sort by are within the $findstr, and it is not possible (at least as far as I know), to sort by a calculated field name.

 

I use the records to create a spreadsheet using PHPExcel, and unfortunately, PHPExcel does not seem to have the functionality to sort the rows before outputting.

 

That leaves me with trying to sort the $records object (if that is possible).

 

So I guess my question is, is that possible, and if it is, how?

 

Any help would be greatly appreciated.

 

Dennis Loughlin

 

 

 

 

$script_result = $fm->newPerformScriptCommand ( 'RSFindsAsOfNew', 'GetAsOf Records from RelatedServices', $asof.'||'.$findstr );

$find_result

= @$script_result->execute ();

 

 

 

if

(FileMaker::isError ( $find_result ))
$objPHPExcel->setActiveSheetIndex(0)->setCellValueByColumnAndRow(1,2, 'no records found');

 

Outcomes