Sort files linked with pointeritem

Is there any built in way to get set a sort order of a file linked to an entity?

In our case, we are using a pointeritem with multiselect to link images to a variant, and I would like to sort these images.

If you’re using the generic pointer with either Files or Images as the entity, the back office field UI supports drag and drop to set the order of the files.

Thanks for the reply. I should have specified that I the question is how to order them programmatically. We recieve a request from our PIM with a certain order, that we would like to add programmatically to the files.

I was thinking about adding a sort order field to the fieldtemplate, but the sort order belongs to the variation rather than the file itself. So this is where I’m wondering if there are any build in ways to add a sort order, if there is a linking object or something that I’m missing. I have search the api and the forum for similar questions but haven’t found a solution there.

When adding a new file to the pointerfield, we first retriev the files that already exist. At this stage, it would be handy to be able to sort them before updating the fields on the pointeritem.

Here is our code for retrieving the fields and adding them to the pointeritem.

var imagePointerItems =
                        fields.GetValue<IList<PointerItem>>(
                            imageFileId);

imagePointerItems?.ToList().ForEach(x => pointerEntities.Add(x.EntitySystemId));

pointerEntities.Add(file.SystemId);

//Could we sort the list here before updating?

fields.AddOrUpdateValue(imageFileId, pointerEntities);

Perhaps there is a way to extend the MultiCulturalFieldContainer to hold a sorting value?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.