Writing a validator that needs to check for newly-added linked issues or attachmentsin the current transitionis a special case. Unfortunately due to deficiencies in the Jira API you need to jump through some additional hoops. This code only applies where you have the Attachments or Issue Links field on the screen. If you can avoid this, you should try to do so. That is, require that the attachments or links are created through the standard operations before the transition is done. It will make your code simpler.
Typically you will get attachments and linked issues from AttachmentManager or IssueLinkManager… however these will only give you newly-added attachments/links once the current transaction has been committed. In a validator it has not as yet.
This in itself makes sense, the API deficiency is that there’s no way to get these things from theissuethat is available to validators.
Validating Attachments Added
The following example details how to find properties of attachments added this transition or on creation, for example the file name. TheAttachmentsfield must be on the transition screen to get attachments like this.
Via the REST API, it’s not currently possible to create an issue with attachments, or add attachments on a transition. The form token above is not available in REST contexts, but because of this limitation it doesn’t matter.
Blocking Files by Extension
You can block files with certain extensions being added using the following script in conjunction with a Simple Scripted Validator: