Hello,
I want to 'read only' field fixVersion in Jira.
In edit screen in is working okay, But in view screen it is not read only and users can edit it.
I tried to use this intialiser without success:
def customField = getFieldByName("Fix Version/s")
customField.setAllowInlineEdit(false)
What am I doing wrong?
Thank you,
Daniel
Hi @Oussama Brik ,
I am not sure to understand fully your problem, but here is a groovy script that will return issues with the label "test" :
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.web.bean.PagerFilter
def jqlSearch = "labels = \"test\""
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
def userManager = ComponentAccessor.getUserManager()
IssueManager issueManager = ComponentAccessor.getIssueManager()
ApplicationUser user = userManager.getUserByKey('berry_a')
List<Issue> issues = null
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch)
if (parseResult.isValid()) {
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
issues = searchResult.results.collect {issueManager.getIssueObject(it.id)}
} else {
log.error("Invalid JQL: " + jqlSearch);
}
return issues
Hope that helps
thanks @Antoine Berry I found a way to solve my prob:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import org.apache.log4j.Level
import org.apache.log4j.Logger
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)
def customFieldManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def GetIssueManager = ComponentAccessor.getIssueManager()
def log = Logger.getLogger("com.acme.workflows")
log.setLevel(Level.DEBUG)
final customFieldName = "customfield_12345"
def IssueCF = customFieldManager.getCustomFieldObject(customFieldName)
def query1 = jqlQueryParser.parseQuery('project = MyProject AND (type = bug) AND (labels is not Empty) ')
def results1 = searchProvider.search(query1, user, PagerFilter.getUnlimitedFilter())
def List1 = results1.issues.collect{issueManager.getIssueByCurrentKey(it.key)}
def query2 = jqlQueryParser.parseQuery('project = MyProject AND (type = task) AND (labels is not Empty)')
def Results2 = searchProvider.search(query2, user, PagerFilter.getUnlimitedFilter())
def List2 = Results2.issues.collect{issueManager.getIssueByCurrentKey(it.key)}
Results2.getIssues().each { documentIssue ->
def Issue2Key = documentIssue.key
def Label2 = documentIssue.labels
String Label2_String = Label2.first()
results1.getIssues().each { documentIssue2 ->
def Issue1Key = documentIssue2.key
def Issue1Object = issueManager.getIssueObject(Issue1Key)
def Issue1Label = documentIssue2.labels
String Label1_String = Issue1Label.first()
def Issue1CF = documentIssue2.getCustomFieldValue(IssueCF)
if(Label1_String.equals(Label2_String) && !Issue1CF){
Issue1Object.setCustomFieldValue(IssueCF, [Issue2Key])
GetIssueManager.updateIssue(user, Issue1Object, EventDispatchOption.DO_NOT_DISPATCH, false)
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.