Hello
I'm trying to create a field validation using behaviour, that I would like to run whenever someone changes the reporter of an issue (during creation or elsewhere in edit mode).
Basically, we need to make sure that the Reporter always belongs to a specific group.
I have tried something like the following, but without success.
//Required Imports
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
def groupManager = ComponentAccessor.getGroupManager()
// Get a pointer to the reporter field and get user
def ReporterField = getFieldById("reporter")
def ReporterValue = ReporterField.value as ApplicationUser
if(groupManager.isUserInGroup(ReporterValue, 'ReportersGroup')){
ReporterField.setError("Reporter must be in Reporters group.")
ReporterField.setFormValue(null)
}else{
// If a valid value is entered clear any errors and accept the value
ReporterField.clearError()
}
Please help!
Hi Mark,
You will need to do the filtering in your rest end point.
So, for a case insensitive search, you will need something like
def templateList = results.issues.collect { issue-> issueManager.getIssueObject(issue.id).getCustomFieldValue(customField) }.findAll {it != null} as List<String>
rt = [
items : templateList?.findAll { it.toLowerCase().contains(query?.toLowerCase())}?.collect { row ->
// rest of the script
}
That should do the trick, ping me if it doesn't :)
Kind regards,
Thanos
Many thanks, @Thanos Batagiannis [Adaptavist]!
It works perfect!
As i noticed, for all time that i work with scriptrunner plugin, many useful things just not described in documentation, like this for example or for setFormValue have examples only for selectlists and textfields and for dates, userpickers, grouppickers need some R&D actions from users.
In my opinion behaviours very poorly documented, I am using Idea and see so many methods in behaviour api, which are not described. It will be great to do JavaDoc for them.
So i have one question.
Do Adapatavist have plans on improving documentation?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mark,
Glad that we made it work.
I hear you and you are right. The thing is that ScriptRunner abilities are endless and no kind of 'traditional' documentation can cover all the cases.
So right now we are working into 2 major areas
The first one is to improve our "traditional" documentation - in progress
The second one is a way to share scripts with the public in a better way than just examples in the documentation - in progress
Regarding the select list conversion issue itself, we are also working in a solution that will make it much more easier and more flexible.
Kind regards and thanks a lot for the feedback,
Thanos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Thanos Batagiannis [Adaptavist] , I have the same issue as @Mark Markov , but with diferent porpose as well as diferent code, isn't for a issue but for a request.
Could you help me also?
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Mark Markov and @Thanos Batagiannis [Adaptavist]
I need to implement something like this:
I want to create a select list field for a particular project with options which appear on screen as:
<value of a custom field(any other custom field) of an issue><space><Value of summary field of the same issue>
and the no. of options should be same as the no. of issues in that particular project.
Could you please help.
Thanks and Regards,
Swapnil Srivastav.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have problem on setting default value on user picker on customer portal. I think I need this one. can you help? @Mark Markov
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.