Hi all,I have a button.
The user enters a phone number into a field. Clicks the button.
The button validates the phone number, adds to 2 fields and clears the entry field.
The reason I have 2 fields is as follows. When the user enters another number, I want the button to check 1 field. If anything exists, then don’t add to both fields, only add to 1 field.
This allows me to have 1 field with the 1st number and the other field with multiple numbers. This is required by the application that processes the document. (I hide the single entry field from the form)
I cannot seem to use LotusScript to check if the field contains anything. I can only find code that you must be specific of what to search for. But what to search for can be different dependant on the user value entered.
I’ve looked at If, Instr, fieldcontains but cannot seem to piece the code to differentiate what action should be taken. I cannot append a count to anther field as the user can manually clear the field.
Any Ideas?
Sub Click(Source As Button)
Dim smsMobiles As String
Dim smsCountry As NotesItem
With doc
smsMobiles = .smsMobiles(0) & ", "
code = .smsCountry(0)
counter = 0
Forall n In .CellPhoneNumber
If Instr( n, "0" ) = 1 Then
newNum = ""
n = Strright( n, "0" )
lenToDo = Len( n )
For i = 1 To lenToDo
theChar = Mid( n, i, 1)
If Instr( "0123456789", theChar ) > 0 Then newNum = newNum & theChar
Next
smsMobiles = smsMobiles & code & newNum & ","
Else
If Instr( n, code ) = 1 Then
newNum = ""
n = Strright( n, code )
lenToDo = Len( n )
For i = 1 To lenToDo
theChar = Mid( n, i, 1)
If Instr( "0123456789", theChar ) > 0 Then newNum = newNum & theChar
Next
smsMobiles = smsMobiles & code & newNum & ","
Else
newNum = ""
lenToDo = Len( n )
For i = 1 To lenToDo
theChar = Mid( n, i, 1)
If Instr( "0123456789", theChar ) > 0 Then newNum = newNum & theChar
Next
smsMobiles = smsMobiles & code & newNum & ","
End If
End If
counter = counter + 1
End Forall
.x = smsMobiles
finalsmsMobiles = Evaluate( |@Implode(@unique( @Explode( x; ", " ));", ")|, doc )
End With
Call uiDoc.FieldSetText( "smsMobiles",finalsmsMobiles(0))
Call uiDoc.FieldSetText( "smsMobile",finalsmsMobiles(0))
Call uiDoc.FieldClear("CellPhoneNumber")
Call uiDoc.Refresh
End Sub