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 notes field loses line breaks via API...???

Featured Replies

We've got an Auctions table with an InternalNotes field that usually has quite a few notes in it. Each new note is separated by a line break so it's easy to read.

I have a PHP script that I'm using to update the Auction record with information from eBay. When the auction ends I'm updating the notes field some new notes.

In order to do that without losing all of the previous notes I'm first pulling the notes from FM into the script, then I append new notes to it and update the record with the new notes.

The problem is when they get back in FileMaker all of the lines have been pushed together like 1 huge sentence. For whatever reason it's losing the line breaks.

Now, in my code for the new notes I'm using chr(13) to add line breaks in the new notes that I'm including and those do work when pushed back into FM, but all of the previous notes get pushed together one long line.

How can I get the previous notes to maintain their line breaks so it doesn't screw it all up when I update the record?

Before I started switching everything for this client over to PHP API I was doing everything via ODBC. The same method was applied in the old ODBC scripts and I didn't have this problem.

Any information on this would be greatly appreciated. Thanks!

Edited by Guest

if the line breaks are present in the value that you pull from the db you could always use str_replace() to swap them out with chr(13)

I've been using 'n' to add a line break and haven't had a problem.

  • 2 years later...

I have exactly the same problem.

$var = "new note" . "\r" . $record->getFieldUnencoded("notes") ; //also tried without "Unencoded" - no change

$edit = $record->setField("notes", $var );

$result = $record->commit();

error_check($result);

If I keep repeating this I'll get

1st attempt:

new note

2nd attempt:

new note

new note

3rd attempt:

new note

new notenew note

4th attempt:

new note

new notenew notenew note

All previous carriage returns are lost on each new update. Anyone know how to solve this?

We've got an Auctions table with an InternalNotes field that usually has quite a few notes in it. Each new note is separated by a line break so it's easy to read.

I have a PHP script that I'm using to update the Auction record with information from eBay. When the auction ends I'm updating the notes field some new notes.

In order to do that without losing all of the previous notes I'm first pulling the notes from FM into the script, then I append new notes to it and update the record with the new notes.

The problem is when they get back in FileMaker all of the lines have been pushed together like 1 huge sentence. For whatever reason it's losing the line breaks.

Now, in my code for the new notes I'm using chr(13) to add line breaks in the new notes that I'm including and those do work when pushed back into FM, but all of the previous notes get pushed together one long line.

How can I get the previous notes to maintain their line breaks so it doesn't screw it all up when I update the record?

Before I started switching everything for this client over to PHP API I was doing everything via ODBC. The same method was applied in the old ODBC scripts and I didn't have this problem.

Any information on this would be greatly appreciated. Thanks!

Have you guys tried using \n or \n\r instead of \r?

Maybe try:

str_replace(array("\n","\n\r","\r"),"\r","new note\r".$record->getFieldUnencoded("notes"));

Failing that, try swapping the \r in the replace statement out for any of the alternatives.

Have you guys tried using \n or \n\r instead of \r?

Maybe try:

str_replace(array("\n","\n\r","\r"),"\r","new note\r".$record->getFieldUnencoded("notes"));

Failing that, try swapping the \r in the replace statement out for any of the alternatives.

wow, your code works.

By the way, writing \n to FileMaker does not work, and \n\r works just as well (or not well) as \r

I guess what is happening here is that you need to write \r to FileMaker for you to see the line break in FileMaker, BUT when you read that field back into php, it substitutes the \r for \n ( for some unknown reason). You need to substitute them back when writing, or you lose your line breaks.

Thanks for your help!

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.