Set correct query on relation table popups