Create new ItemNode with ItemsAllowed.One

How to create one item of a specific type so that under treeview in management client I have only one node without possibility to add more. I have created single item in ItemManager, something like:

 public override void Init()
        {
            
            fqid.Kind = CaptisDefinition.CaptisKind;
            fqid.ObjectId = Captis.CaptisDefinition.itemGuid;
            //fqid.ServerId = Configuration.Instance.ServerFQID.ServerId;
            fqid.ParentId = Guid.Empty;
            if (GetItem(fqid) == null)
            {
               
                CurrentItem = new Item(fqid, "Default");
                
                Configuration.Instance.SaveItemConfiguration(CaptisDefinition.CaptisPluginId, CurrentItem);
            }
            else
            {
                fqid.ServerId = Configuration.Instance.ServerFQID.ServerId;
                CurrentItem = GetItem(fqid);
                Configuration.Instance.SaveItemConfiguration(CaptisDefinition.CaptisPluginId, CurrentItem);
            }
        }

Also in PluginDefinition, I specified ItemsAllowed.One.

Above code gave me an errors, so firstly I used fqid.ServerId in commented line, but after event server being restarted I had to remove that line and now everything is ok, but that’s not way to go :slight_smile:

Any suggestions on how to properly implement that part?

The way we normally suggest doing this is not by loading hardcoded item in Init method (which would also mean that item being updated later on by someone else would not be read), but instead simply change item manager like this:

Define a hardcoded ID for the configuration item, modify the ItemManager class in a way that the FillUserControl()-method always uses this configuration item instead of its parameter, and the ValidateAndSaveUserControl()-method saves the data to this configuration item