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?

Parents Reply Children
  • 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");
                }
            }
        }
    }