So I believe that the parentId can be null if you want to create the dictionary item within the root of the dictionary area. However, if you want to nest the item under an existing dictionary item, then you'd need to pass the parent ID as a GUID.
You can get the IDs of the root items by calling LocalizationService.GetRootDictionaryItems() which returns all the root items. Each item will have a property called Key which is the GUID you need to pass as the parent to create a child item.
Create Dictionary item from code
Hi! How can I create dictionary item from code?
You'd use the LocalisationService and call the
CreateDictionaryItemWithIdentity()
method to programmatically create a dictionary item.Thank you for the answer!! I see that there must be a parentId in the CreateDictionaryItemWithIdentity method, where can I get this?
Hi! So the signature to the CreateDictionaryItemWithIdentity method looks like this:
CreateDictionaryItemWithIdentity(string key, Guid? parentId, string defaultValue = null)
So I believe that the
parentId
can be null if you want to create the dictionary item within the root of the dictionary area. However, if you want to nest the item under an existing dictionary item, then you'd need to pass the parent ID as a GUID.You can get the IDs of the root items by calling
LocalizationService.GetRootDictionaryItems()
which returns all the root items. Each item will have a property calledKey
which is the GUID you need to pass as the parent to create a child item.Many thanks
is working on a reply...