HTML email macros crashing, missing and not word wrapping
Hi All,
We've recently upgraded to 1.9 from 1.8.1 and have been having trouble with the new HTML email compose editor.
I see three types of odd behaviour.
1. Firstly, if all the text is removed from the editor (backspace everything, select all and delete, select all cut, or just press backspace in a fresh empty window) followed by inserting a macro, the window crashes for the user (message is "An application error has occurred. Your session has been reset"). It doesn't affect the other windows open for the user, or any other users. The response is a 500 status error from the server, tomcat logs are:
Apr 13, 2017 1:19:37 AM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [AppServlet] in context with path [/openvpms] threw exception java.lang.NullPointerException at java.io.StringReader.<init>(StringReader.java:50) at echopointng.ui.util.HtmlNodeLexer.doTokenize(HtmlNodeLexer.java:85) at echopointng.ui.util.HtmlNodeLexer.lex(HtmlNodeLexer.java:76) ... truncated because of forum spam block
Macros insert OK provided there is some text already in the body before insert.
2. Another issue, is that if you insert a macro into the email, then click send, the inserted macro is not sent in the email. This is particularly nasty since there's no way to know unless you check the sent emails, or send them to yourself!. Typing any text after inserting the macro seems to make it better.
3. Finally, and a less critical issue, but annoying none the less - If inserting a macro with long text, it doesn't get wrapped in the email editor. The text runs out into horizontal scrollbars. This seems to be because non-breaking spaces are inserted in the macros instead of normal spaces.
I have a workaround for this, Cut all, then paste as plain text (Ctrl+A, Ctrl+X, Ctrl+Shift+V in Chrome on Windows). This works, but it's a pain!
I've tried working around this, but can't find any configuration which has an effect. Happy to dig deeper and provide logs as required.
Cheers,
-Jesse
Re: HTML email macros crashing, missing and not word wrapping
Jesse:
1) I cannot duplicate your first problem (crash on inserting macro on empty window), tried both 1.9.1 (7410) and 2.0 (7425). Tim A may ask you to provide the full error log as this provides more information.
2) I can duplicate your second (fill email body just from macro text with no additional typing - appears on screen but not in sent email or in the comms log entry) - so this is a real bug. [Tim A - I have not raised the Jira as a I have a suspicion that the NPE is part of the same problem.]
The work-around is to press the enter key after you have invoked the macro and it has expanded its text onto the screen.
3) Long lines coming in from macros do not get line wrapped: I am 99.9% certain that this was a design choice. During development/testing I seem to remember that we switched from 'text from macros is just like typing' (so that lines wrap at the margin) to 'text from macros is formatted as is' (so that long lines do not wrap at the margin).
This was explicitly done to preserve the formatting/layout of the text coming in from macros - and it was needed to keep column layouts in text coming in from maros that invoked a report to generate text.
The work-around/correct approach is to set up the expression so that it is pre formatted, ie instead of using "This is a long line of text which is longer than the email write window width and thus should really be adjusted into two lines so that it displays without scroll bars", you use:
concat("This is a long line of text which is longer than the email write window width and thus should really",$nl, "be adjusted into two lines so that it displays without scroll bars")
Or (far easier), if you are just using text, break it into lines in the macro expression - ie
See http://www.openvpms.org/documentation/csh/1.9/admin/lookup/macro for more.
I have also just tweaked the Email Write Screen help text - see http://www.openvpms.org/documentation/csh/1.9/common/email - to say
Regards, Tim G
Re: HTML email macros crashing, missing and not word wrapping
1. Raised as https://openvpms.atlassian.net/browse/OVPMS-1877
2. Raised as https://openvpms.atlassian.net/browse/OVPMS-1878