I have several fields on a form that I do not want the users to be able to enter a carriage return. The data, via a Notrix job goes into another system and if the user does a carriage return on these fields it will error out in the other system.
For each field I have entered the following formula in the Input Translation:
@Trim(@ReplaceSubstring(@ThisValue; @NewLine : @Char(10) : @Char(13); “”))
This is not working. Any suggestions?
Subject: No carriage return on free form fields
Do you need to account for each element in the list?
@Trim(@ReplaceSubstring(@ThisValue; @NewLine : @Char(10) : @Char(13); “”:“”:“”))
Subject: RE: No carriage return on free form fields
Just tried the formula and it looks fine. Is this field a multivalue field and you wish to make a long sting? If so you want @implode
@Implode( textlistValue ) or
@Implode( textlistValue ; separator )
Subject: RE: No carriage return on free form fields
I am still unable to get this to work. I have the formula in the Input Translation is that correct? Anything else I need to check for the field properties?
Subject: RE: No carriage return on free form fields
Did you get this to work? You can do the formula in the notrix job as well
Subject: RE: No carriage return on free form fields
Yes I got this to work!! Thanks, really appreciate all of the responses and help!!
Subject: RE: No carriage return on free form fields
You could write code in the QuerySave event.I do that in many of my applications, that way you have all the code in one place, and you can even list the fields that need to be filled out in one message box instead of displaying one field after another.
You can also do much more advanced verifications. Below is an example from one of my applications (abbreviated):
'*** BI Injury Type fields
If source.FieldGetText("Claimant_Category") = "BI" Then
If source.FieldGetText("BIIT_Primary")="" Then
If source.FieldGetText("Claimant_Injured")="Yes" Then
Msgbox "You must enter at least one BI Injury Type",MB_ICONSTOP,"Empty Field"
Call source.GotoField("BIIT_Primary")
continue = False
Exit Sub
End If
Elseif source.FieldGetText("BIIT_PrimaryCategory")="NCO" Then
Call source.FieldSetText("BIIT_Secondary","")
Call source.FieldSetText("BIIT_SecondaryCategory","")
End If
If source.FieldGetText("BIIT_SecondaryCategory")="NCO" Then
Msgbox "You can not select 'NCO' for secondary BI Injury Type",MB_ICONSTOP,"Invalid Value"
Call source.GotoField("BIIT_Secondary")
continue = False
Exit Sub
End If
End If
' *** Check fields for line breaks and other invalid characters
If HasLineBreak(source.FieldGetText("Claimant_FirstName")) Or _
HasLineBreak(source.FieldGetText("Claimant_LastName")) Or _
HasLineBreak(source.FieldGetText("Claimant_MiddleInitial")) Then
Msgbox "You can not have line breaks in the claimant name.",MB_OK+MB_ICONSTOP,"Invalid Character"
continue = False
cancelsave = True
Exit Sub
End If
If HasLineBreak(source.FieldGetText("Claimant_Company")) Then
Msgbox "You can not have line breaks in the company name.",MB_OK+MB_ICONSTOP,"Invalid Character"
continue = False
cancelsave = True
Exit Sub
End If
If HasLineBreak(source.FieldGetText("Claimant_Address")) Or _
HasLineBreak(source.FieldGetText("Claimant_Address2")) Then
Msgbox "You can not have line-breaks in the claimant address.",MB_OK+MB_ICONSTOP,"Invalid Character"
continue = False
cancelsave = True
Exit Sub
End If
As you can see, I actually check for linebreaks here, using a function I wrote:
Function HasLineBreak(value As String) As Integer
If Instr(value,Chr$(13))>0 Then
HasLineBreak = True
Elseif Instr(value,Chr$(10))>0 Then
HasLineBreak = True
Else
HasLineBreak = False
End If
End Function