AddValueListItem Method does not commit the item to the list.

Hi,

Trying to add an item to a value list using the AddValueListItem Method using this code in a workflow script (grabbed from an example Craig created a while back)

     Dim objValueListItem: Set objValueListItem = CreateObject("MFilesAPI.ValueListItem")
     objValueListItem.Name = sItemName
     'objValueListItem.ValueListID = iValueListId
     Vault.ValueListItemOperations.AddValueListItem iValueListId, objValueListItem, True
     Err.Raise mfscriptcancel, objValueListItem.ID &", name "& sItemName  &", list "& iValueListID

 The code always returns 0 as objValueListItem.ID, the other values are as expected.

When checking the content of the valuelist after running the code, no new items appear. However, if you manually add a new item this new item will skip a number of ID numbers equivalent to the number of times the code has been run since last. It looks as if the code reserves an ID but never commits the new item.

What can I do to make sure the code commits the new item?
The code runs in a function that will be called multiple times in a "for each" loop.
I need to pick up the new IDs in a collection of lookups that can be committed as property value in a multiselect lookup at the end of the script.

Thanks for any hints, Karl