IF statements for strings containing unpaired parentheses

Discussions related to ReadyDoc development.
Post Reply
amtech
Posts: 9
Joined: Tue May 24, 2022 5:51 pm

IF statements for strings containing unpaired parentheses

Post by amtech »

I ran into this issue and couldn't find a solution here, so I thought posting both the problem and solution might be helpful to others.

I was having an issue where an unpaired opening or closing parenthesis was causing the Order.ExistingLiens.Recording.AdditionalInfo field to not complete an IF statement and not render IF used in a IF statement. My guess is that when Select parses the IF statement, it expands the string and treats the next parenthesis it encounters as part of the IF statement rather than ignoring any special characters in the string.

Code: Select all

<FOREACH {{Order.ExistingLiens}}>
<IF (Not IsEmpty( {{.RecordingInformation.AdditionalInfo}} ) and {{.RecordingInformation.AdditionalInfo}} <> "")>

Notes:
{{.RecordingInformation.AdditionalInfo}}
</IF>
</FOREACH>
An example of a value in the AdditionalInfo field that will cause this issue is below:

Code: Select all

a) Substitute Mortgage A in the amount of $1,000,000.00 and b) Substitute Mortgage B in the amount of $500,000.00.
The workaround for this error is to reverse the logic by checking for the values I didn't want and moving the AdditionalInfo to an ELSE statement, as below.

Code: Select all

<FOREACH {{Order.ExistingLiens}}>
<IF (IsEmpty( {{.RecordingInformation.AdditionalInfo}} ) or {{.RecordingInformation.AdditionalInfo}} = "")><ELSE>

Notes:
{{.RecordingInformation.AdditionalInfo}}
</IF>
</FOREACH>
Not that there is no issue if the field is not checked in an IF statement.

Code: Select all

<FOREACH {{Order.ExistingLiens}}>
	Additional Info.:	{{.RecordingInformation.AdditionalInfo}}	
</FOREACH>
I'm sure that there are other special characters or combinations of special characters that will also raise create unexpected output that this may or may not resolve, e.g. "{{" break the IF statement and display document code.

The below in the AdditionalInfo field:

Code: Select all

a{{ Substitute Mortgage A in the amount of $1,000,000.00 and b) Substitute Mortgage B in the amount of $500,000.00.
Renders on a document as as:

Code: Select all

<IF ( IsEmpty( "a"" = ““)><ELSE>

Notes:
"a{{ Substitute Mortgage A in the amount of $1,000,000.00 and b) Substitute Mortgage B in the amount of $500,000.00."
</IF>
</FOREACH>
Post Reply