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.

Pulling info out of a newly created entry

Featured Replies

  • Newbies

Im creating a new entry using FMNew() and I have a ID# that is generated for every new entry (in my FM DB) but I can't seem to be extract the info.

<?php

include_once('FX/FX.php');

include_once('FX/server_data.php');

include_once('FX/FMErrors.php');

$user=$_POST ["user"];

$newrecord=new FX($serverIP,$webCompanionPort);

$newrecord->SetDBData("demandereparation.fp5","Web");

$newrecord->AddDBParam("user",$user);

$newResult=$newrecord->FMNew();

?>

I try to extract the FM variable ID but I always get an error.

I tried adding this to my code to get it to show.

foreach($newResult["data"] as $key=>$newData)

{}

echo $newData ["ID"][0];

I also tried to print_r($newData) but it's empty but the new record was successfully created in my FM DB.

Any help would be greatfully appreciated.

Thanks

  • Author
  • Newbies

Finally found an answer. Didn't know I could simply add another instance that did a FMFind(). Everything works great.

New code if this can help others

<?php

include_once('FX/FX.php');

include_once('FX/server_data.php');

include_once('FX/FMErrors.php');

$user=$_POST ["user"];

$newrecord=new FX($serverIP,$webCompanionPort);

$newrecord->SetDBData("demandereparation.fp5","Web");

$newrecord->AddDBParam("user",$user);

$newResult=$newrecord->FMNew();

foreach($newResult["data"] as $key=>$newData)

{}

$recordDetails=explode(".",$key);

$currentRecord=$recordDetails[0];

$recid=$currentRecord;

$findrecord=new FX($serverIP,$webCompanionPort);

$findrecord->SetDBData("demandereparation.fp5","Web");

$findrecord->AddDBParam("-recid",$recid);

$findResult=$findrecord->FMFind();

foreach($findResult["data"] as $key=>$findData)

{}

echo $findData["ID"][0];

?>

Hi siroisv,

I am working on a survey page with 150 quesions, I am having some problem to keep adding information to a related record where I have I have several webpage instead one. Do you have any idea how should I have it working?

thank you,

msei :confused:

Hello,

You're method works, but you're wasting precious resources by making hitting the DB twice. Here's a less verbose method with just a single hit and you can grab the recid or any other field you want:


$Add = new FX($serverIP,$webCompanionPort);

$Add->setDBData('users.fp7','layout');

$Add->AddDBParam('firstname','$FirstName');

$Add->AddDBParam('lastname','$LastName');

$AddResult=$Add->FMNew();



// Assuming you trapped for all errors and successfully added the new record...

foreach($AddResult['data'] as $AddKey=>$AddRecord)

$FMRecordID = explode('.',$AddKey);

$CurrentAddRecord = $FMRecordID[0];

$UserID = $AddRecord['UserID'][0]



echo "Record ID: ".$CurrentAddRecord";        // Grab the recid

echo "User ID: ".$UserID";                              // Grab data from 'UserID' field

In this example, I add a new record to users.fp7. My table has a serial number field, users:UserID, that is autopopulated with a serial number in FileMaker. Sometimes, I need the recid, other times I need the serial number.

Hope this helps,

Shannon

-=-=-

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.