[FX.php List] How to get recid of new record

Steve Winter steve at bluecrocodile.co.nz
Tue Jun 30 00:28:15 MDT 2009


Hi John,

Since you're doing an FMNew, and therefore know that you're only going  
to get one record back you can add;

	$recordPointers = explode('.', key($records));

now $record pointers will be an array which has two elements, 0 will  
be the recid, 1 the modid, so;

	$recid = $recordPointers[0];

alternatively you can use the list() 'function';

	list($recid, $modid) = explode('.', key($records));

this way you don't need any calculation fields in FM, or foreach loops  
in PHP...

This will always work, not just when creating records, however if the  
returned data set contains more than one record, you will end up with  
the details for the first record, which may not always be what you  
want ;-)

Cheers
Steve


On 30 Jun 2009, at 05:39, John Funk wrote:

> I have this code below that creates a record in FM.
> How to I get the record id of the record just created?
>
> $request = new FX($ServerIP, $port, 'FMPro7');
> $request->SetDBData($db, 'web_requests','1');
> $request->SetDBUserPass($fmAccount, $fmPass);
> $request->AddDBParam('AccountNumber', $AccountNumber);
> $request->AddDBParam('ContactName', $ContactName);
> $request->AddDBParam('Phone', $Phone);
> $request->AddDBParam('Email', $Email);
> $result = $request->FMNew();
> $records = $result['data'];
>
> // this part  below does not work
> foreach($records as $record)
> {
> $RequestRecID=$record['a_ID'][0];  // a_ID is the calculated field  
> to get the recid
> echo $RequestRecID;
> }
>
> Thanks in advance.
> John
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list


Steve Winter
steve at bluecrocodile.co.nz
m: +44 77 7852 4776
3 Calshot Court, Channel Way
Ocean Village, Southampton SO14 3GR

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20090630/c0c89e1c/attachment.html


More information about the FX.php_List mailing list