We've just published a new blog post on creating CUI buttons that are enabled/disabled based on some conditions. The example we used in the blog post was how to ensure that users can only run an action when multiple items are selected in the grid. You can find this blog here: https://community.aras.com/b/english/posts/conditional-cui-buttons
Hope this helps!
Aras Labs Software Engineer