You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I have a custom field(not script field) 'Team'. I created another custom field 'teamCopy' and used the below script to copy values of 'Team' to 'copyTeam'. It worked. When I go to issue navigation, 'copyTeam' custom field shows the values are copied successfully but when I filter the search with a 'copyTeam' value it doesn't show any result. What am I missing?
the goal is to go to issue nagivation and filter by 'teamCopy' value e.g. CRC.360 and get the result which I'm not getting but without filter the teamCopy Column shows the copied values.
Here is the code. I ran the script in script runner script console.
import com.atlassian.jira.CompomemtManager;
import com.atlassian.jira.issue.CustomManager;
import com.atlassian.jira.fields.CustomId;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.utilDefaultIssueChangeHolder;
import com.atlassian.jira.MutableIssue
import com.atlassian.jira.search.SearchProvider;
import com.atlassian.jira.jql.parser.JqlQueryParser;
import com.atlassian.jira.web.bean.PagerFilter;
import com.atlassian.jira.event.type.EventDispatchOption
import java.sql.Timestamp;
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)
def issueManager = ComponentAccessor.getIssueManager()
der user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def query = jqlQueryParser.parseQuery('Team is not empty')
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
results.getIssue().each{documentation ->;
MutableIssue issue = issueManager.getIssueObject(documentIssue.id)
log.setLevel(org.apache.log4j.Level.DEBUG)
//this is team object
def field_pp = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName('Team')
def ppText = issue.getCustomFieldValue(field_pp).toString();
log.debug("teamval :${ppText}");
//this is teamCopy object
def field_se = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName('teamCopy')
def seText = issue.getCustomFieldValue(field_se);
field_se.updateValue(null, issue, new ModifiedValue(seText, ppText), new DefaultIssueChangeHolder());
log.debug("teamval :${seText}");
issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED,false);
issue.setUpdated(new Timestamp(System.currentTimeMillis()));
}