Hi,
We have a radio button field, if it is yes then it should check whether is there any attachment in the smart attachment field
Smart attachment has category in its attachment field, we will have to check if the attachment is present in that attachment category
Then if both mentioned above are yes then the transition should happen else it should throw error message 'Upload attachment'
Remember if radio button field has NO in it, then it should not restrict the transition, it is only if it is yes then it should check for attachment and throw error.
Current script is not working, and it is attached here, can you pls help with this?
Below is the script
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.AttachmentManager
//Get the issue and the custom field value
Issue issue = issue
def customFieldValue = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("LLD Configuration Requirement"))
// Check if the custom field is "yes"
if (customFieldValue == "Yes") {
// Get the attachment manager
AttachmentManager attachmentManager = ComponentAccessor.getAttachmentManager()
// Check if the issue has attachments
if (attachmentManager.getAttachments(issue).isEmpty()) {
// If there are no attachments, throw an error return false
}
}
//If the custom field is not "yes" or there are attachments, allow the transition return true
Regards.