The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi. i want to change text custom field's string to other custom text field. I can do it with description (system field) field but cant do with custom field. i marked description where i wanna enter other custom field. Pls help
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.CommentManager
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
import com.atlassian.jira.plugin.webfragment.model.JiraHelper
import com.jirahelpers.JiraIssueParameterUtil
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.util.json.JSONObject
import groovy.json.JsonBuilder
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import org.apache.log4j.*
import com.jirahelpers.JiraIssueParameterUtil
import com.jirahelpers.ProcessMatrixUtils
import com.jirahelpers.InsightObjectsUtils
import com.atlassian.jira.issue.customfields.manager.OptionsManager
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
def cField1 = customFieldManager.getCustomFieldObject("customfield_13237")
def cField2 = customFieldManager.getCustomFieldObject("customfield_13245")
def cFieldValue1 = issue.getCustomFieldValue(cField1)
def cFieldValue2 = issue.getCustomFieldValue(cField2)
final getCustomFieldValues1 = issue.getCustomFieldValue(cField1)
final getCustomFieldValues2 = issue.getCustomFieldValue(cField2)
issue.description.replace("branchname","$getCustomFieldValues1")
Looking at your code, I assume you are doing this from a Post-Function.
You could try something like this:-
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.customFieldManager
def sampleEmail = customFieldManager.getCustomFieldObjectsByName('Sample Email').first()
def sampleEmailValue = issue.getCustomFieldValue(sampleEmail) as String
def textToList = customFieldManager.getCustomFieldObjectsByName('Text to List').first()
def textToListValue = issue.getCustomFieldValue(textToList) as String
issue.setCustomFieldValue(textToList, "${textToListValue} ${sampleEmailValue}".toString())
Please note that the sample code provided is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below are the screenshots of the Post-Function configuration:-
1) When creating the Post-Function select ScriptRunner's Custom script post-function as shown below:-
2) Next, add the code as shown below.
Next, save the config and publish the changes.
Below are a few test screenshots:-
1) Create a new issue and enter some values into the text fields as shown below and create the issue.
2) Once the ticket is created, you will notice both the fields have their respective value, as shown below:-
I hope this helps to answer your question. :)
Thank you and Kind regards,
Ram
Thank you very much. Resolve that, i only need (.to String)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.