Hello,
I struggle with "if" statement and components in Behaviors for Service Desk.
My goal is to make the Events field mandatory if there's a required value in Components and Company fields. It must happen on the customer portal during a request creation, not in a created issue.
The script I work on:
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import groovy.transform.BaseScript
def issue = getIssueContext()def company = getFieldByName('Company')
def components = getFieldByName('Components')
def events = getFieldByName('Events')
String companyval = company.getValue()
String componentsval = components.getValue()
if (companyval == "Company name" && componentsval == ('value'))
{
events.setRequired(true)
}
I understand that the way I work with components is wrong, what should I do in this case? Actually, if there's only companyval in the "if" statement, then it works ok but it breaks with components.