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.

getField() in infinite loop

Featured Replies

  • Newbies

Hello,

I want to have a script pause when a field is not empty, and to continue as it is not empty any more.

So I tried this infinite loop:

while (1 == 1)
{
   echo "Test if field is empty..." . "<br>";
   $val_block = $record->getField("web_block_n");
   if ($val_block == "") {break;}
   echo "wait for field is not empty..." . "<br>";
   sleep(5);            
}

Result: When field "web_block_n" has already been empty, the loop breaks immediately as expected.

But if the field is not empty before the php script starts, and I make it empty after start, nothing happens.

The browser from where the script was called, is just in wait mode, and no echo output at all is shown.

What is wrong?

 

Thank You

Wolfgang

 

Well, it would - where is the web submit to actually make the field in the database change?

The web is not like FM - you need to actively make a change, and then that value will persist in the web browser until another call is made...

  • Author
  • Newbies

I change (and save) the field by hand, directly, in the FM layout, while the script is running.

The complete code is like this:

    $theCommand = $fm->newCompoundFindCommand($layoutName);
    $request = $fm->newFindRequest($layoutName);
    $request->addFindCriterion('web_identifier_x', "identifier_a");
    $theCommand->add(1, $request);
    $resultfm = $theCommand->execute();
    $records = $resultfm->getRecords();
    foreach ($records as $record)
    {
      ...
      while(1)
      {
            $val_block = $record->getField("web_block_n");
            if ($val_block == "") {break;}
            sleep(3);
      }
      ...
    }

I there something I miss? Do I have to repeat i.e. getrecords(), or execute() as well inside of the loop ?

Wolfgang

  • Author
  • Newbies

OK solved: I had to include the execute() and getrecord() calls and the foreach(record) into the loop as well.

Wolfgang

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.