How to remove extra carriage return on a generated text file in Appian
0085117,000011.55,000011.55CRLF0052514,000035.00,000035.00CRLFCRLF
Discussion posts and replies are publicly visible
Is this file generated with the Text Doc from Template node?
load( /*This expression should be 100% - 9-19-19 */ local!lines:if( rule!APN_isEmpty(ri!DIRDEP_LINES), {"NO DATA,000000.00,000000.00" }, { a!forEach( /*replace test array with rule input*/ items: ri!DIRDEP_LINES, expression: { /* Position 1-7 (7) CCDDEP_ACCOUNT_NO */ substitute(padleft(trim(fv!item.caseId),7)," ",0) & "," & /* Position 9-17 (9) CCDDEP_AMT */ if(rule!APN_isEmpty(fv!item.paymentAmt), substitute(padleft(trim(fv!item.paymentAmt),9)," ",0), substitute(padleft(trim(fixed(fv!item.paymentAmt)),9)," ",0) ) & "," & /* Position 19-27 (9) CCDDEP_AMTR */ if(rule!APN_isEmpty(fv!item.paymentAmt), substitute(padleft(trim(fv!item.paymentAmt),9)," ",0), substitute(padleft(trim(fixed(fv!item.paymentAmt)),9)," ",0) ) } ) }), joinarray(stripwith(local!lines,";"),chr(13)&CHR(10)) )
The code looks like this.
The text file is generated dynamically when the process model runs.
I would start with removing the curly brackets in lines 8, 12, 33, 36. This turns a simple list of strings into a list of list of a single string.
Just to confirm, that expression will return a text value - but to convert the result it into a document, you must be running it through something such as the Text Doc From Template smart service? E.g. my first step would be to confirm the template itself does not contain the extra line break, if this is the case.
I'm also surprised the chr() function is working for you as the documented function we typically use for this in Appian is fn!char().
I think I found the template. Please see attached image
Is the expression above inserting text into the replacement field ###line###? Because if you're doing that but then not passing in any text for ###trailer### then you will automatically have an extra carriage return at the end of your text file, no matter what. Can you post a screenshot of the configuration of the text from template node?
the ###header### is the only item called in the node for generating the txt file. But that same template is used by other nodes to include ###header### , ###line###, and ###trailer###
I would say that if the line break issue is only with the document created in this process, create a new copy of the template, remove everything in it except "###header###", and point this process to use the new template.
I may have misread different process vs different nodes within the process, I would verify all scenarios such as - are all 3 inputs always used (assuming no since you have blanks), does the line break issue occur for every process or only where ###trailer### and/or ###line### are blank, etc. If you need to remove blanks for different scenarios, you could utilize a few different templates OR combine your expressions from those other nodes into 1 along where you add the ###header###.