I am using the following code to try and create contacts and set a note for each one. The contacts are being created properly, but the notes are not being set. I don't get any compile or runtime errors, it just doesn't add a note to the contact:
The reason I am setting a note is because I am using this code to delete certain contacts that contain the note that I set:
Why isn't my SetNote code working?
B4X:
Sub Globals
Dim btnAdd As Button
Dim btnRemove As Button
Dim etxQuantity As EditText
Dim quant As Int
End Sub
Sub etxQuantity_TextChanged (Old As String, New As String)
'limit EditText view to 3 digits
If New.Length > 3 Then
etxQuantity.Text = Old
'move the cursor to the end of the view
etxQuantity.SelectionStart = etxQuantity.Text.Length
End If
'make sure EditText view isn't blank, then set the value to the variable quant
If etxQuantity.Text <> "" Then
quant = etxQuantity.Text
Else
quant = 0
End If
End Sub
Sub btnAdd_Click
Dim thisContactID As cuContact
If quant > 0 Then
Msgbox("Creating fake contacts! (please be patient)", "Nice!")
For i = 1 To quant
thisContactID = cu.InsertContact("#" & DateTime.Now, "")
cu.SetNote(thisContactID.Id, "Fake contact")
Next
Else
Msgbox("Enter a quantity first.", "Hey!")
End If
End Sub
The reason I am setting a note is because I am using this code to delete certain contacts that contain the note that I set:
B4X:
Sub btnRemove_Click
Msgbox("Deleting all fake contacts! (please be patient)", "Sweet!")
Dim deleteTheseContacts As List = cu.FindContactsByNotes("Fake contact", True, False)
For Each c As cuContact In deleteTheseContacts
cu.DeleteContact(deleteTheseContacts)
Next
End Sub
Why isn't my SetNote code working?