I have an SDK script I'm using to try to clear and repopulate a template field list. When I use the line For i As Integer = 0 To fieldList.Count - 1 I get an Index out of Range error.
If there are 7 values in the template field list and I use For i As Integer = 0 To 3 the script removes every other value.
Here's the script:
Try
'Get a reference to the field that contains the list...
Dim myField As FieldInfo = Field.GetInfo("Send To Packet", Me.RASession)
'Instantiate a copy of the list itself...
Dim fieldList As List(Of String) = myField.GetItemList
'Step through the list and remove all items...
For i As Integer = 0 To fieldList.Count - 1 **This gives an Index out of Range error
‘For i As Integer = 0 To 3 ** This removes every other value
fieldList.RemoveAt(i)
Next
'add items in ListOfPacketFolders to the template list
'for each x as string in FolderList
' fieldList.Add(x)
'next
'Persist the changes...
myField.SetItemList(fieldList)
myField.Save()
'Cleanup...
myField = Nothing
fieldList = Nothing
Catch ex As Exception
'Pass any error messages back to workflow...
WorkflowApi.TrackError(ex.Message)
End Try
Thanks!