Hello All,
I am looking for a way to concatenate the (Custom field Field Value Followed by Affect/s Version) as a Summary of the issue using Script runner Behavior. Although, part of the Script works but it adds '_null', so it seems not able to recognize the Affect/s Version values.
{code}
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.SUMMARY
import static com.atlassian.jira.issue.IssueFieldConstants.AFFECTED_VERSIONS
@BaseScript FieldBehaviours fieldBehaviours
/**def AffectsVersion = getFieldByName("Affects Version/s").value**/
def AffectsVersion = getFieldByName(AFFECTED_VERSIONS).value
def Product = getFieldByName("Product Techno").value
def summary = getFieldById("summary")
summary.setFormValue("${Product}_${AffectsVersion}")
{code}
Please refer the attached screen shot.
Kindly let me know how can i fix this?
Hi @Manu Mishra,
There you go, tested with Behaviour and works:
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.SUMMARY
import static com.atlassian.jira.issue.IssueFieldConstants.AFFECTED_VERSIONS
@BaseScript FieldBehaviours fieldBehaviours
/**def AffectsVersion = getFieldByName("Affects Version/s").value**/
def AffectsVersion = getFieldById("versions").value
def Product = getFieldByName("Product Techno").value
def summary = getFieldById("summary")
summary.setFormValue("${Product}_${AffectsVersion}")
I placed the same script on the custom field and the Affected Version field.
Thanks @mogavenasan It works at my side as well. However, how can i remove the braces around the affects version/s from summary.
Also is it possible to validate the *Affects Version/s* from this project/type to accept only ONE version?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Since you are using Behaviour, you can validate the number of elements in the list. If it's more than 1, clear the field value and prompt the user to enter only one value.
The braces around the value is because of the list. Try AffectsVersion[0].
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The id for Affect/s Version is "versions". Also, you can simply use something like:
def versions = getFieldById("versions").value.toString()
def product = getFieldByName("Product Techno").value.toString()
getFieldById("summary").setFormValue("${product}_${versions}")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Max Lim _Adaptavist_ This is working perfectly. However, only concern is to remove the braces around the affect Version/s from jira summary.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are many ways to do it, you can do it with string manipulation methods:
def versions = getFieldById("versions").value.toString().replace("[","").replace("]","")
def justText = getFieldByName("Just Text").value.toString()
getFieldById("summary").setFormValue("${justText}_${versions}")
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.
Hi @Manu Mishra ,
I think the main problem is Affects Version/s field returns list of versions, even if there's only one version stored.
I'm not sure, if it suitable for you to work only with the first one version, or you need to get all the versions and put the names together.
Please try...
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.