Copied custom field doesn't show up in search issue navigation when filtered by it.

Taposh Das September 27, 2019

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()));
}



 

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events