Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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")

 

1 answer

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 29, 2022

Hi @Javid Huseynli

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:-

post_function_config1.png

2) Next, add the code as shown below.

post_function_config2.png

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.

image1.png

2) Once the ticket is created, you will notice both the fields have their respective value, as shown below:-

image2_before_transition.png

image2_before_transition.png

image3_after_transition.png

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) 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events