items_count_limit does not work
Closed this issue · 3 comments
Brief bug description
I am attempting to modify an existing content type and add a linked items with a items_count_limit
restriction but it does not work.
Repro steps
- Make sure you have a content type you want to create a migration to add a new linked items item.
- For the value of the modification, add
items_count_limit
. Specify the condition and value. - Compile the TypeScript migration into JavaScript.
- Run the migration with
kontent migration run -n test -e DEV
. - Check your Kentico project to see the results.
- Notice the
items_count_limit
had no effect.
Expected behavior
I expect the items_count_limit
restriction to apply.
Additional context
Below is my migration code.
const migration: MigrationModule = {
order: 1,
run: async apiClient => {
await apiClient
.addContentType()
.withData(BuildChecklistItemType)
.toPromise()
await apiClient
.modifyContentType()
.byTypeCodename('checklist')
.withData(ChecklistModification)
.toPromise()
},
}
const BuildChecklistItemType = (
builder: ContentTypeElementsBuilder,
): ContentTypeModels.IAddContentTypeData => ({
codename: 'checklist_item_1',
elements: [
builder.textElement({
codename: 'text',
is_required: true,
name: 'Text',
type: 'text',
}),
],
name: 'Checklist Item 1',
})
const ChecklistModification: ContentTypeModels.IModifyContentTypeData[] = [
{
op: 'addInto',
path: '/elements',
value: {
allowed_content_types: [
{
codename: 'checklist_item_1',
},
],
codename: 'items_1',
is_required: true,
items_count_limit: { // LOOK HERE
condition: 'exactly',
value: 4,
},
name: 'Items 1',
type: ElementModels.ElementType.modularContent,
},
},
]
Here is the result in Kentico:
Everything worked as expected except the items_count_limit
.
Please let me know if I can provide any additional information. Thank you! :)
Hi,
accoring to documentation you are using incorrect name of property items_count_limit
Try to set item_count_limit instead of items_count_limit
@michalpaukert Goodness, I totally missed this! Thanks for clearing that up. I got confused because this is what the linked items interface looks like from kontent-management
:
interface ILinkedItemsInType extends IElementInContentType {
items_count_limit: {
value: number;
condition: 'at_most' | 'exactly' | 'at_least';
};
allowed_content_types?: SharedContracts.IReferenceObjectContract[];
name: string;
guidelines?: string;
type: 'modular_content';
codename?: string;
external_id?: string;
content_group?: SharedContracts.IReferenceObjectContract;
}
Thanks again for clearing that up though! :)
This is probably bug in kontent-management SDK, I will check it and take steps to fix it.
Edit: new version of kontent-management had been deployed.