How to use system field 'ID' in filter function


when adding a new dataset, i want to adjust a filter.
but couldn’t select system field ‘ID’.


What can i do? Please help

Sincerely

Not sure, if i can help you, because i can not speak “chinese”.
But anyway, did you first connected your dataset with your DATA-COLLECTION?

Did you choose the right options → READ / WRITE / Read&Write ???

You don’t need to speak chinese, it’s just the screenshots :slight_smile:

If you open the Properties of a dataset and try to add a filter, you cannot choose the ID (_id) field to filter on. It’s not present in the dropdown.

Would be nice to add a filter on ID, so that the filter doesn’t break if the Title field changes. For example if working with a collection that holds an enumeration.

As a workaround to this short-coming I have added an extra field called “publicID”, which can be filtered on. Next I add a data-hook BeforeInsert (and perhaps onBeforeUpdate to update existing items) to copy the hidden _id to publicID.

export function Specialisaties_beforeInsert ( item , context ) {
item . publicId = item . _id ;
return item ;
}

Kind of a dirty way of doing, but it’s the best I have come up with if you want to stay with using Dataset Settings instead of Page Code

1 Like