[FX.php List] Re: FX.php_List Digest, Vol 129, Issue 11

Gary Frieders gfried at sonic.net
Wed Jul 15 15:20:02 MDT 2015


I have not been successful connecting FX to FMS 13 or 14.
Had to go back to FMS 12 until I change all my web sites to FMP API.

Unless someone knows how to connect FX to FMS 13 or 14.

Gary Frieders

> On Jul 15, 2015, at 7:40 AM, fx.php_list-request at mail.iviking.org wrote:
> 
> Send FX.php_List mailing list submissions to
> 	fx.php_list at mail.iviking.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://www.iviking.org/mailman/listinfo/fx.php_list
> or, via email, send a message with subject or body 'help' to
> 	fx.php_list-request at mail.iviking.org
> 
> You can reach the person managing the list at
> 	fx.php_list-owner at mail.iviking.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of FX.php_List digest..."
> 
> 
> Today's Topics:
> 
>   1. RE: Search Results To Text File -- SOLVED! (VanBuskirk, Patricia)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Wed, 15 Jul 2015 14:40:07 +0000
> From: "VanBuskirk, Patricia" <pvanbuskirk at fsu.edu>
> Subject: RE: [FX.php List] Search Results To Text File -- SOLVED!
> To: FX.php Discussion List <fx.php_list at mail.iviking.org>
> Message-ID:
> 	<7731A5AA5FC88D48831221524FB9D8901C466481 at fsu-exch-nwr03.fsu.edu>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> That looks MUCH better!  Thanks, Malcolm!
> 
> p.s. Using FM11 now, but converting to 14 soon.
> 
> 
> From: fx.php_list-bounces at mail.iviking.org [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Malcolm Fitzgerald
> Sent: Tuesday, July 14, 2015 6:09 PM
> To: FX.php Discussion List
> Subject: Re: [FX.php List] Search Results To Text File -- SOLVED!
> 
> Unless you are working with FMP8 you have the Quote( ) function and the List( ) functions available. They work together nicely to make this sort of code legible.
> 
> let (
> row = List (
>    quote( Business_Unit ) ;
>    quote ( WO_ID ) ;
>    quote ( Descr254 ) ;
>    ...
> ) ;
> substitute ( row ; ķ ; "," )
> )
> 
> 
> 
> On 15/07/2015 2:44 am, VanBuskirk, Patricia wrote:
> So, I was able to get it to work by creating a calculated field in the database that created the line of formatted info I needed for the export.  Then, I used the fwrite function.
> 
> FM field ( named cf_lineForExport ) :
> 
> "\"" & Business_Unit & "\",\"" & WO_ID & "\",\"" & Descr254 & "\",\"" & WO_Type & "\",\"" & Shop_ID & "\",\"" & Srvc_Grp_ID & "\",\"" & Priority_CD & "\",\"" & Status_CD & "\",\"" & Status_DTTM & "\",\"" &
> Right ( "00"& Month (  REQ_Start_Dt ) ; 2 ) & "/" & Right ( "00"& Day (  REQ_Start_Dt ) ; 2 ) & "/" & Year (  REQ_Start_Dt ) & "\",\"" &
> Right ( "00"& Month (  REQ_End_Dt ) ; 2 ) & "/" & Right ( "00"& Day (  REQ_End_Dt ) ; 2 ) & "/" & Year (  REQ_End_Dt ) & "\""
> 
> PHP code :
> 
> $fp = 'C:\\Temp\\NewOMNI.txt';
> 
> echo "<br>Found Records: ".count($searchResult)."<br>";
> 
> foreach ($searchResult as $record) {
> 
>            $line .= $record['cf_lineForExport']."\r\n" ;
>            file_put_contents($fp, $line, FILE_APPEND | LOCK_EX);
> 
> }
> fclose($fp);
> 
> 
> Comes out perfectly!  Thanks again for all the tips and ideas!
> 
> Trish V.
> 
> 
> From: fx.php_list-bounces at mail.iviking.org<mailto:fx.php_list-bounces at mail.iviking.org> [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of VanBuskirk, Patricia
> Sent: Tuesday, July 14, 2015 7:41 AM
> To: FX.php Discussion List
> Subject: RE: [FX.php List] Search Results To Text File
> 
> Thanks Malcolm and Dale!  I will check out your suggestions today.  I truly appreciate the help!  I'll let the group know what ends up working.
> 
> From: fx.php_list-bounces at mail.iviking.org<mailto:fx.php_list-bounces at mail.iviking.org> [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Malcolm Fitzgerald
> Sent: Monday, July 13, 2015 5:59 PM
> To: FX.php Discussion List
> Subject: Re: [FX.php List] Search Results To Text File
> 
> There are two other considerations. First, you must escape your field delimiters if they occur within the data. Second, what are the rules concerned your record delimiter, if it appears within the data. Lots of import programs give record delimiters a higher priority than field delimiters causing all sorts of mess.
> 
> This function was amongst the comments on the fputcsv page at php.net. I modified it slightly, the original by R dot Mansveld at Spider-IT dot de, didn't quote numerals.
> 
> function fwritecsv($handle, $fields, $delimiter = ',', $enclosure = '"') {
>    # Check if $fields is an array
>    if (!is_array($fields)) {
>        return false;
>    }
>    # Walk through the data array
>    for ($i = 0, $n = count($fields); $i < $n; $i ++) {
>            # Duplicate in-value $enclosure's and put the value in $enclosure's
>            $fields[$i] = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $fields[$i]) . $enclosure;
>    }
>    # Combine the data array with $delimiter and write it to the file
>    $line = implode($delimiter, $fields) . PHP_EOL ;
>    fwrite($handle, $line);
> 
>    # Return the length of the written data
>    return strlen($line);
> }
> 
> Malcolm
> 
> On 14/07/2015 8:37 am, Dale Bengston wrote:
> 
> Hi Trish,
> 
> 
> 
> If your fields are in the same order coming off your FileMaker layout as you'd like them in the file, you can make a string out of each record's data and write it to your file, using fwrite instead of fputcsv:
> 
> 
> 
> foreach ($searchResult as $record) {
> 
>  $line = '"' . implode('","', $record) . '"' . "\n";
> 
>  fwrite($fp, $line);
> 
> }
> 
> 
> 
> My email probably made those double quotes into typesetting quotes, so you'll probably have to put them back to straight quotes if you copy from here.
> 
> 
> 
> Just a thought.
> 
> 
> 
> Dale
> 
> 
> 
> On Jul 13, 2015, at 2:53 PM, VanBuskirk, Patricia <pvanbuskirk at fsu.edu><mailto:pvanbuskirk at fsu.edu> wrote:
> 
> 
> 
> Unfortunately, yes.  It is being FTP'd to a holding directory and then picked up and imported into a PeopleSoft inventory system.  So, either it CANNOT or they WILL NOT use any other formatting.  Either way, that is the "golden" program around here, and FileMaker is hated and looked down upon.  So the odds of getting that changed are lower than that of zombies invading the Earth.
> 
> 
> 
> 
> 
> From: fx.php_list-bounces at mail.iviking.org<mailto:fx.php_list-bounces at mail.iviking.org> [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Malcolm Fitzgerald
> 
> Sent: Monday, July 13, 2015 3:46 PM
> 
> To: FX.php Discussion List
> 
> Subject: Re: [FX.php List] Search Results To Text File
> 
> 
> 
> Hi Patricia,
> 
> 
> 
> Are you absolutely sure that every field MUST have double quotes around it?
> 
> 
> 
> The whole point of CSV is to pass it onto another app. Is the app that you are passing the data to rejecting the file?
> 
> 
> 
> Malcolm
> 
> 
> 
> 
> 
> 
> 
> On 14/07/2015 6:44 am, VanBuskirk, Patricia wrote:
> 
> Hi guys, I think I'm really close.  I'm getting it to create the file, but I am struggling with the format. Each field needs to have double quotes around it, as in the following example:
> 
> 
> 
> "FSU01","RN260715","Facilities Department - MENDENHALL BUILDING A (MMA) - 969 LEARNING WAY","RN","OTC","OTC","1","OPEN","","5/19/2015","5/19/2016"
> 
> "FSU01","RN260815","Procurement Services & Help Desk - UNIVERSITY CENTER - BLDG. A (UCA) - 282 CHAMPIONS WAY","RN","OTC","OTC","1","OPEN","","5/20/2015","5/20/2016"
> 
> "FSU01","TSR0299915","Medicine College of Dean's Office - COM -THRASHER BLDG. 1115 W CALL ST","TSR","OTC","OTC","2","OPEN","","5/20/2015","5/20/2016"
> 
> 
> 
> Here's how it's coming out now.  It is putting a little square when the carriage return should be, and the fields are not being surrounded by quotation marks.  I tried using the $delimiter and $enclosure parameters, but they put random quotation marks in (maybe just around text fields?).  I can get it to echo to the page properly, by using  ... '"'.$field1.'","'.field2 ... etc.
> 
> 
> 
> <image001.png>
> 
> 
> 
> Here's my code:
> 
> 
> 
> <?php
> 
> 
> 
> define('DEBUG', TRUE);
> 
> require_once('FX.php');
> 
> require_once('server_data.php');
> 
> require_once('FMErrors.php');
> 
> 
> 
> 
> 
> $search=new FX(FM_IP, FM_PORT, FM_VERSION);
> 
> $search->SetDBData('WorkOrders_TST.fp7','SeeALL');
> 
> $search->SetDBUserPass(FM_USERNAME, FM_PASSWORD);
> 
> $search->AddDBParam('Status_CD', 'OPEN');
> 
> $search->AddDBParam('ExportTimestamp', null);
> 
> $search->AddDBParam('REQ_Start_Dt', ' * ');
> 
> $search->AddDBParam('REQ_End_Dt', ' * ');
> 
> $search->AddDBParam('Descr254', ' * ');
> 
> $searchResult = $search->DoFXAction('perform_find');
> 
> 
> 
> $fp = fopen("C:\\Temp\\NewOMNI.txt", "w");
> 
> 
> 
> echo "<br>Found Records: ".count($searchResult)."<br>";
> 
> 
> 
> foreach ($searchResult as $record) {
> 
> 
> 
>            $linearray=array($record['Business_Unit'],$record['WO_ID'],$record['Descr254'],$record['WO_Type'],$record['Shop_ID']);
> 
>    fputcsv ( $fp , $linearray, $delimiter = ',', $enclosure = '"' )."\l" ;
> 
> }
> 
> fclose($fp);
> 
> 
> 
> echo("<br>Error Code: {$search->lastErrorCode}<br>");
> 
> echo("FileMaker Error Message: {$errorsList[$search->lastErrorCode]}<br><br>");
> 
> echo "Error: ".$searchResult['errorCode'];
> 
> 
> 
> ?>
> 
> 
> 
> I have been messing with this darn thing for several days now, so any tips or direction given will be greatly appreciated!
> 
> 
> 
> Trish
> 
> 
> 
> 
> 
> From: fx.php_list-bounces at mail.iviking.org<mailto:fx.php_list-bounces at mail.iviking.org> [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Steve Winter
> 
> Sent: Thursday, July 9, 2015 4:01 PM
> 
> To: FX.php Discussion List
> 
> Subject: Re: [FX.php List] Search Results To Text File
> 
> 
> 
> Hi Patricia
> 
> 
> 
> So - if you're already using FX, then it should be pretty simple. In pseudo code
> 
> 
> 
>   * create a brand new layout and place the fields you need to export, in the order you need to export them on that layout from top to bottom (this may sounds mad, but what it will mean is that when the FX array of records comes back the fields will be in the right order)
> 
>   * do a find for the records which need to be exported
> 
>   * use http://php.net/manual/en/function.fopen.php to create a file resource
> 
>   * feed the file resource and the FX array of returned records into http://php.net/manual/en/function.fputcsv.php which Joel suggested
> 
>   * close the file using http://php.net/manual/en/function.fclose.php
> 
> 
> 
> HTH
> 
> Steve
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Hi Steve (and Joel),
> 
> 
> 
> We are currently using FMS 11Adv, but have plans to upgrade to 14 as soon as budget is approved (as fast a herd of turtles around here).
> 
> 
> 
> That robot has been in use using a script running plug-in for years, importing orders from the web, then creating a csv of certain info for our PeopleSoft folks to import into their inventory system (which is why ODBC is not an option).  They have very specific formatting that they must have or their import will fail.
> 
> 
> 
> Anywho.... I have replaced the import portion of it through FX, but haven't yet figured out how to do the export part.
> 
> 
> 
> Thanks again for your responses!
> 
> 
> 
> Trish
> 
> 
> 
> 
> 
> -----Original Message-----
> 
> From: fx.php_list-bounces at mail.iviking.org<mailto:fx.php_list-bounces at mail.iviking.org> [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Steve Winter
> 
> Sent: Thursday, July 9, 2015 3:36 PM
> 
> To: FX.php Discussion List
> 
> Subject: Re: [FX.php List] Search Results To Text File
> 
> 
> 
> Hi Patricia
> 
> 
> 
> There are many different ways to solve this problem ;-)
> 
> 
> 
> Which version of FM server are you using...? it's certainly possible with both 13 and 14 to export records to csv with a server-side script, so this is going to be the simplest way to go about it.
> 
> 
> 
> Otherwise either FX or the PHP API could also be used with a scheduled task.
> 
> 
> 
> Cheers
> 
> Steve
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Hi Group!
> 
> 
> 
> Is there a way, using fx.php to create a csv text file of search results on the FM or web publishing server?
> 
> 
> 
> Example of how we need the results,
> 
> 
> 
> "FSU01","TSR0002216","Information Technology Services (ITS) - ","TSR","OTC","OTC","2","OPEN","","07/06/2015","07/06/2016"
> 
> "FSU01","TSR0002316","Arts & Sciences College of - ","TSR","OTC","OTC","2","OPEN","","07/08/2015","07/08/2016"
> 
> "FSU01","TSR0002916","Information Technology Services (ITS) - ","TSR","OTC","OTC","2","OPEN","","07/09/2015","07/09/2016"
> 
> "FSU01","TSR0003016","Alumni Association - ","TSR","OTC","OTC","2","OPEN","","07/09/2015","07/09/2016"
> 
> 
> 
> We presently have a "script robot" set up that exports a file every 1/2 hour within a FM client.  We are trying to get rid of that FM installation and automate it through php.  I was actually trying to run a FM script through FM Server, but it seems export is not a permitted script step for server script scheduling.
> 
> 
> 
> Any assistance would be greatly appreciated!
> 
> 
> 
> Trish
> 
> _______________________________________________
> 
> FX.php_List mailing list
> 
> FX.php_List at mail.iviking.org<mailto:FX.php_List at mail.iviking.org>
> 
> http://www.iviking.org/mailman/listinfo/fx.php_list
> 
> 
> 
> Steve Winter
> 
> +44 777 852 4776
> 
> steve at bluecrocodile.co.nz<mailto:steve at bluecrocodile.co.nz>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> 
> FX.php_List mailing list
> 
> FX.php_List at mail.iviking.org<mailto:FX.php_List at mail.iviking.org>
> 
> http://www.iviking.org/mailman/listinfo/fx.php_list
> 
> _______________________________________________
> 
> FX.php_List mailing list
> 
> FX.php_List at mail.iviking.org<mailto:FX.php_List at mail.iviking.org>
> 
> http://www.iviking.org/mailman/listinfo/fx.php_list
> 
> 
> 
> Steve Winter
> 
> +44 777 852 4776
> 
> steve at bluecrocodile.co.nz<mailto:steve at bluecrocodile.co.nz>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> 
> FX.php_List mailing list
> 
> FX.php_List at mail.iviking.org<mailto:FX.php_List at mail.iviking.org>
> 
> http://www.iviking.org/mailman/listinfo/fx.php_list
> 
> 
> 
> _______________________________________________
> 
> FX.php_List mailing list
> 
> FX.php_List at mail.iviking.org<mailto:FX.php_List at mail.iviking.org>
> 
> http://www.iviking.org/mailman/listinfo/fx.php_list
> 
> 
> 
> _______________________________________________
> 
> FX.php_List mailing list
> 
> FX.php_List at mail.iviking.org<mailto:FX.php_List at mail.iviking.org>
> 
> http://www.iviking.org/mailman/listinfo/fx.php_list
> 
> 
> 
> 
> 
> _______________________________________________
> 
> FX.php_List mailing list
> 
> FX.php_List at mail.iviking.org<mailto:FX.php_List at mail.iviking.org>
> 
> http://www.iviking.org/mailman/listinfo/fx.php_list
> 
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20150715/57751a8b/attachment.html
> 
> ------------------------------
> 
> _______________________________________________
> FX.php_List
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
> 
> End of FX.php_List Digest, Vol 129, Issue 11
> ********************************************
> 



More information about the FX.php_List mailing list