I think I’ve found a reasonably generic approach here that might work, and that doesn’t define an extra field. What do you think of this?