Hello Atlassian heroes,
I would like to make attachments mandatory (under condition) at issue creation (Customer portal).
Here is my scenario : IF customfield1 = value1 AND customfield2 = value2 THEN attachment is mandatory.
To achieve this, I did create a "Simple Scripted Validator" at Create transition.
Here is my script :
import com.atlassian.jira.component.ComponentAccessor
def attachmentManager = ComponentAccessor.getAttachmentManager()
def hasAttachments = attachmentManager.getAttachments(issue).size() >= 1
if (cfValues['customfield1']?.value == "value1" && cfValues['customfield2']?.value == "value2" && !hasAttachments){
return false
} else {
return true
}
I did also try this :
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.AttachmentManager;
def attachments = issue.getAttachments();
if (cfValues['customfield1']?.value == "value1" && cfValues['customfield2']?.value == "value2" && attachments.size() >= 1){
return false
} else {
return true
}
But I got this kind of error :

Can you please help me achieve this ?
Jira Software version : 8.15.0
Jira Service Management version : 4.15.0
Script Runner version : 6.20.0
THANKS A LOT !