Hi,
This is the general forum, so I'm not sure which Dynamic 365 app you're using.
But as my understanding, most of the buttons can be customized on ribbon workbench,
for example, the image below can be edited to have the button appear with the condition that at least one record is selected:
We can define its maximum value in order to control when the button can be displayed.
Further, you can write JS to modify the behavior of the button.
If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more.
Please feel free to contact me if you have any further questions.
Regards,
Haig