Its not going to be possible to do this in JIRA Cloud.
With JIRA Server, you can leverage the Script Runner add-on: https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner
For more details, please reference this previously posted questions - they aren't identical but are similar in nature:
Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot