Jump to content

Pulling notes field loses line breaks via API...???


This topic is 4847 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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
Link to comment
Share on other sites

  • 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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This topic is 4847 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.