Hi @mac_doggie,
here is a good post that explains how you can handle and implement the logic you want to achieve.
Hope this helps.
Regards Michael