Destroying (deleted) value list item with list connected to external database.

We are using M1 as our database which doesn't allow auto incrementing primary keys, and it creates a problem for inserting and deleting items. My insert statement finds the current max value of the ID and adds one. After deleting the max value through the database, I am not able to add a new value since M-Files still holds onto the ID but just in (deleted) form. I've tried creating an M-Files Server application to destroy/remove the item but have not been successful with it. Is there a good work around for this?

  • Found a work around in the last hour. I temporarily disconnect the database connection to be able to change deleted items. I input the GUID into my M-Files Server Application to get the ObjID and use the ObjID to set the External ID to "Not available". Then after reconnecting the database I am able to create a new value list item.

  • Here is my code if anyone is interested:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using MFilesAPI;
    
    namespace RemoveValueListItem
    {
        public class Program
        {
            static void Main(string[] args)
            {
                Vault kageVault = null;
                try
                {
                    var mfServerApplication = new MFilesServerApplication();
    
                    mfServerApplication.Connect(MFAuthType.MFAuthTypeLoggedOnWindowsUser);
                    VaultsOnServer vaults = mfServerApplication.GetVaults();
                    foreach (VaultOnServer vault in vaults)
                    {
                        if(vault.Name == "Kage")
                        {
                            kageVault = vault.LogIn();
                            break;
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Failed to connect to M-Files");
                }
                
                if (kageVault != null)
                {
                    var objID = kageVault.ObjectOperations.GetObjIDByGUID("{B343C430-4C9D-4FAF-A2AD-4F2F361E1EAA}");
                    kageVault.ObjectOperations.SetExternalID(objID, "Not available");
                    MessageBox.Show("ID Changed");
                }
            }
        }
    }