Hi All,
We have a requirement to copy field value from Summary to Ticket Summary (Text field) and Description to Ticket Description (Text Field ) .
Can some one help with the listner script to achive.
your inputs are highly appreciated.
Thank you,
Varun
For your requirement, you can try something like this:-
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
def issue = event.issue as MutableIssue
def customFieldManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def sampleTextField = customFieldManager.getCustomFieldObjectsByName('Sample Text Field').first()
def sampleMultiLineText = customFieldManager.getCustomFieldObjectsByName('Sample Multi Line Text').first()
def description = issue.description
def summary = issue.summary
if (summary && description) {
issue.setCustomFieldValue(sampleTextField, summary)
issue.setCustomFieldValue(sampleMultiLineText, description)
issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
}
Please note that the sample code provided is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the Listener Configuration:-
Below are a few test screenshots for your reference:-
1. First, when creating a new issue, only the values for the Summary and Description fields are entered.
2. Once the issue has been created, as expected, the values from the Summary and Description fields are copied to the Sample Text Field and Sample Multi Line Text field accordingly, as shown in the screenshot below:-
3. If the Summary field is updated, the Sample Text Field is updated accordingly, as shown in the screenshots below:-
4. Similarly, if the Description field is updated, the Sample Multi Line Text field is updated accordingly, as shown below:-
I hope this helps to solve your question. :)
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_ ,
Thanks for the script,
It is working as expected.
Thank a lot for your support.
Regards,
Varun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Ram,
Does this works for Select list field also?
I have requirement where values entered in the one single select list should be displayed in another field select list field..
We have created Database picker field to achieve this. is it possible to do it using only normal scripted field or behaviour?
Find the configuration script below:
import com.atlassian.jira.issue.Issue
import com.onresolve.scriptrunner.canned.jira.fields.editable.database.SqlWithParametes
getSearchSql = { String inputValue, Issue issue, String originalValue ->
// return SqlWithParameters, that will control the search SQL..., eg:
new SqlWithParameters("""
select customfieldoption.customvalue, customfieldoption.customvalue as customvalue2 from customfieldoption
left join configurationcontext
on customfieldoption.customfieldconfig = configurationcontext.fieldconfigscheme
where customfieldoption.customfield=10400
and configurationcontext.project=?
and lower(customfieldoption.customvalue) like '%' || lower(?) || '%' and customfieldoption.disabled = 'N' order by customfieldoption.customvalue asc
""", [issue.projectId, inputValue])
}
getValidationSql = { String id, Issue issue, String originalValue ->
// return SqlWithParameters, that will control the validation SQL..., eg:
new SqlWithParameters("""
select customfieldoption.customvalue, customfieldoption.customvalue as customvalue2 from customfieldoption
left join configurationcontext
on customfieldoption.customfieldconfig = configurationcontext.fieldconfigscheme
where customfieldoption.customfield=10400
and configurationcontext.project=?
and customfieldoption.customvalue = ?
""", [issue.projectId, id])
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's not the same for the Database Picker.
You can use the Behaviour to update the field based on the option selected from the DB Picker. Still, you will need to do some filtration, i.e. pull the value displayed in the DB Picker, query it via SQL and put the result in the destination field.
I suggest you take a look at this Adaptavist Library example for more information.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.