How to use 'Contains' operator and concatenate strings within Behaviors

Adiel Segal January 2, 2019

Hi all,

 

I'm trying to create a behavior, in which will be a field called "PVPCommit" that in general will populate the current value that appearing in the "Fix version" field(Standard system field). if the value in the 'Fix version' will change, the behavior should notice that so that the current value under "Fix version" will concatenate to the 'old' fix version values that already apear under the "PVPCommit" field, for example in the following way: V9.16, V9.18, V9.19. 

Currently, I'm a bit stuck because of two syntax errors that unfortunately I didn't manage to solve yet.  

This is the code that I'm using right now:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;

def issueManager = ComponentAccessor.issueManager;

def PVPCommited

def FIX = getCustomFieldValue("fixVersions")
def FVER = FIX as java.lang.String

if (PVPCommited == null){
PVPCommited = FVER
return PVPCommited
}
else if (PVPCommited.contains(FVER)){
PVPCommited = (PVPCommited + " ," + FVER)
return PVPCommited
}

 

First error-related to this row: else if (PVPCommited.contains(FVER)){

Second error-related to this row: PVPCommited = (PVPCommited + " ," + FVER)

 

By the way, do you think that "Behavior" is the right platform for realizing my need? Is the code I wrote should appear in the "Initializer" part?
I am pretty new to the whole story of building scripts in Jira, any help will be appreciated.

Thanks

Adiel

 

0 answers

Suggest an answer

Log in or Sign up to answer