Hi community,
I'm trying to add users in the multi-user picker custom field based on the selection of a value in the Insight Object field.
There is an "Asset" schema, it has many objects, one is "Operating System", under the OS we have child objects, like "Windows 10", "Windows Server", "CentOS", "Red Hat" etc. I created an insight field and configured the Operating System object to display Name, and the field is associated with a Jira Software project. In the create screen I'm able to see all values from the "Operating System" insight dropdown field. I have a multi-user picker custom field (Approver). By default, it is adding 'user1' and 'user2' in the custom user field but I want it to change users based on value selection from the Operating System field. I wrote the below behaviour script, but it's not working with the if statement. How can I make it works?
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeFacade
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade
@WithPlugin('com.riadalabs.jira.plugins.insight')
@BaseScript FieldBehaviours fieldBehaviours
def oSystem= getFieldById('customfield_10403')
def custApr = 'projLead'
if(oSystem.value == 'Windows 10') {
custApr = 'wUser1, wUser2, wUser3'
}
def customAprFormField = getFieldById('customfield_10410')
customAprFormField.setFormValue(custApr)
Thank you