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
Hi @Pavel
Component field returns multiple values (array/list), that's why you can't match the value of the field with a single value.
Try this one below
if (company.getValue()?.find { it.name == "Company name" }) {
events.setRequired(true)
}
Thank you so much! However, the code doesn't work, I tried to change it to fit my code, but no luck. Is there any other way how to check if array/list contains a required value? I know that I also can use company.contains, but it doesn't work too.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Both the contains() and the find() methods should work.
Could you please add some logs to understand if the code has been through the if clauses, etc?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually, it is up to your preference. You can use any logging approach to see how your code works. For instance, you can use log.error('log details') method.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you sure? I don't think toString() could be apprepriate there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.