I’ve had this peculiar issue wherein, I have to copy paste data from an excel sheet that has each column separated by a colon.
It worked properly when using Internet Explorer, but there was an issue when copy pasting into the same long edit box using Google Chrome. Here’s the code that I had used and that which had worked in Internet Explorer. For reference purposes,I had used IE 8 and Google Chrome v36.
Here’s the sample data that was copy-pasted to the long edit box – each entry appears in its own line:
A : B : C : D
1 : 2 : 3 : 4
E : F : G : H
RECORD.LONGVALUE field is the long edit box on the field
The following code would work in IE without any problems.
Substitute(RECORD.LONGVALUE.Value, Char(10), "");
But, if you use the same code from Chrome, then the second line’s content just before the first colon would get appended to the end of the first line. This is because, the newline character behaves differently in Google Chrome unlike in IE.
IE takes a newline character as just \n(ASCII character 10)
Google Chrome takes a newline character as just \r \n(ASCII character 13 + ASCII character 10)
I tried to come up with a common approach that would work for both IE and Chrome, but in vain. Finally, this is what I came up with – if you have a better approach, please feel free to add it in the comments section.
Long code short, look at what browser is being currently used – set the line break to be in-line with the browser.
You can get the current browser in PeopleCode using
Evaluate %Request.BrowserType When = "IE" RECORD.LONGVALUE.Value = Substitute(RECORD.LONGVALUE.Value, Char(10), ""); break; When = "CHROME" RECORD.LONGVALUE.Value = Substitute(RECORD.LONGVALUE.Value, Char(10), Char(13)); break; End-Evaluate;
Hope this helps! 🙂 The next series of posts would be centered around PS Query and couple of unique PeopleCode scenarios. Until then, Adios! 🙂