<cr> & <lf> Epicor & Report Builder

I have a report issue I’m trying to resolve (SSRS/Report Builder). The comments field from JobOp is on several reports we use in production. Recently I was asked to update that fields’ format with a DMT file and it worked just fine. Spacing is as intended with a separate line for each line of text.

The problem is when the field is modified manually now after that DMT, I seem to loose the format of the text separated into lines. I’ve tried using all kinds of combinations of Chr(10) and Chr(13) along with and without VbCrLf. One of the combinations (I can’t even remember which one now) worked to separate each line of the manually entered text but then added an additional line to the DMT text. Is there a way to manage the differences within Report Builder or do I need to have the text (special characters) adjusted somehow in the text that was brought in with DMT? When I view the special characters from each example they look to be formatted the same to me.

The first image below shows the Special characters existing in the text for CR and LF. The First group(yellow) is the manually entered text in the comments field. The 2nd group (green) is text in the comments fields that came in thru DMT.

The 2nd image below, shows one of the report results. First part was the manually entered text, 2nd & 3rd parts were the comments that came from DMT.

Any help is appreciated! I’m not a code writer by the way - I typically find my answers be searching this forum or Google! :slightly_smiling_face: Just not having a lot of luck with this one.

image

I have used the replace to show the comments in our SO form report, as they are written
=REPLACE(Fields!OrderDtl_OrderComment.Value, chr(13), VbCrLf)

Pierre

3 Likes

I know the following works, I just don’t remember how. I save things that are successful but sometimes forget what problem they solved.

Enter this in the Code section of a report

Public Function SplitComments(ByVal str As String) as String
Dim c() As String = Nothing
dim s as string = ""
c = str.Split(vbcrlf)
Dim i As Integer
For i = 0 To c.Length - 1
If i > 0 Then
s = s & vbCrLf & c(i)
Else
s = c(i)
End If 
Next
return s
End Function

Then you can use a formula like this in the report body.

=IIf(InStr(Code.SplitComments(Fields!LineDesc.Value),VbCrLf) > 0, LEFT(Fields!LineDesc.Value,InStr(Code.SplitComments(Fields!LineDesc.Value),VbCrLf)), Fields!LineDesc.Value)
4 Likes

Thank you Pierre - I am using the Replace with that line, but it’s not helping. Thank you

Thank you John;
i’ll give this a try and let you know how it goes.

Hi John;
so back on to this problem this morning and I’m struggling. Likely because I barely understand any code writing.
image

I’m assuming not putting in exactly right or not putting it in the correct place within the code section.


Any hints in the right direction is appreciated!

If you click off of the report in the gray area, that will bring up the Report Properties. The first line in the Properties is the Code section where you need to paste the first part I sent.

Ok - that helped! However I’m only getting the first line of the Text now.

Have you made the field taller? The text is probably wrapping.

Yes - that was the first thing I thought as well. Extended the length and height and made sure the “allow height to increase” box was checked.

Shoot! I should not have given you the expression, just the code. I must have needed just the first line at some point. Told you I could not remember what my notes were for! Try this in a text box instead:

=Code.SplitComments(Fields!JobOper_CommentText.Value)

That worked thank you! I am still getting extra lines in the Text field where the information was brought in by DMT, which was part of my original problem. This will work for now, but if you have any thoughts on getting rid of those extra blank lines I’ll try it. In the screen shot below the first was entered thru a manual update the operations comment field. The 2nd shows comments that were brought in through a DMT. Any idea’s on why they would be different? When I pull them into Notepad++ they both show the same LF and CR codes.

image

I believe you do not have to put CRLF in if you are DMT’ing something that already recognizes a new line. If you want to DMT it in, I would do one or the other of the following:

Jackets & Weights:
Ladle Add:
Temp:
Timing:
Dump/Table:
Notes:

OR

Jackets & Weights: CRLF Ladle Add: CRLF Temp: CRLF Timing: CRLF Dump/Table: CRLF Notes:

Thank you for all your help (and patience with me) John! The DMT files originally came in just fine, one line for each as expected with no extra empty lines. Then someone made a manual change to the DMT’d text for one part and all the text ended back one big group without LF or CR being recognized even though it was there. I’m going to do some more testing with how that manual text is entered by the user to see what I can do with that, which seems to be the root of my problem!

No problem, happy to help.

1 Like

So what piece of this formula indents the first row of data? If I want to get rid of the indent, what do I need to change?

Public Function SplitComments(ByVal str As String) as String
Dim c() As String = Nothing
dim s as string = “”
c = str.Split(vbcrlf)
Dim i As Integer
For i = 0 To c.Length - 1
If i > 0 Then
s = s & vbCrLf & c(i)
Else
s = c(i)
End If
Next
return s
End Function

image

It should not be indenting. I would copy and paste the text into Notepad++ and see if there is anything that appears in front.

1 Like

John,
Pasting into notepad++ yielded nothing.

It looks like my customized form induced the indent. Thank you for helping me identify the issue.
image

1 Like