Comments
-
With the code above , you're bypassing the UI's permission check and going directly against the objects. You don't need to be the owner. But if your requirement is to change the owner at the same time as you want to change the permissions, you can do that with the PortalPage.Builder() def portalPageBuilder = new…
-
Inf the "fields" configuration for the behavior, select the correct workflow for your project. Then, against your custom field that you want to be read-only, click the "add new condition" and select Except and Workflow Action = Create (1). What this will do is make the field read-only except when the user is in 1-RTE or…
-
You can use getActionName() if(getActionName() == 'Create' || userIsInGroup){ field.setReadOnly(false) } else { field.setReadOnly(true) }
-
Interesting idea. I have played with class loader to be able to load custom class in the console. But I'd never tried to load existing classes. Playing around with your code and what I had before I got this to respond apparently correctly in the console: def load_class = "com.atlassian.jira.component.ComponentAccessor"…
-
You could use groovy.time.TimeCategory.minus(end, start) to get a groovy.time.TimeDuration def endDate = new Date() def startDate = new Date().parse("dd/MM/yyyy","11/1/2019") groovy.time.TimeCategory.minus(endDate , startDate) That script in the console outputs: 301 days, 9 hours, 44 minutes, 23.499 seconds But you can…
-
Assuming your sprints are in an array, you could just sort them. def lastSprindByEndDate = sprints.sort{it.endDate}.last() def lastSprintName = lastSprintByEndDate.name def lastEndDate = lastSprintByEndDate.endDate
-
You can do something like this def area = issue.getCustomFieldValue(areaCustomFld) issue.assignee = defaultAssigneeForArea[area.value]
-
Yes, that should work in the console. The error was my bad... you need to add "new" in front of JsonBuilder
-
Breaking it down ... You want * All the parents of open sub-task matching certain parameters plus * All the children (regardless of status) of the items in #1 So in JQL: issueFunction in parenstOf("query1") OR issueFucntion in subTasksOf ('issueFunction in parenstOf("query1")') That may not be a very performant JQL, but…
-
Yes, having to create so many new roles would be an issue. So what you need it a way to store a different default assignee for each Options of the Area custom field. And that might be different for different projects? One way to perhaps do that would be to use custom project properties. import…
-
Look at the file permission and ownership for the script files. When you edited it, perhaps you rendered it unreadable by the users that jira is running as in your environment.
-
No, behaviours only work on main jira screens. Structure and bulk change from the navigator won't run the logic. But searching should be possible. The data is stored as free text. Bust you can change the searcher to "Exact Txt searcher" if you want to be able to have individual values indexed (and available in JQL…
-
Do you know that you can manage script edit permission via the /plugins/servlet/scriptrunner/admin/settings page? You can't remove the system-admin permissions, but you can decide which other admin groups to include.
-
Behavior script only executed when you change TO a project/issue type that is in the mapping. When you change FROM a mapped issue type or project to one without mapping, then no script is executed. So if you set your mapping to All Project and All Issue Types and start your script this way: def myMapping = [projects:…
-
Here is an idea, just create a new project role. Then you can just populate that project role with 1 or more users that you want to include in your notifications. Then your custom listener can just pull the members of that role from the current project. import com.atlassian.jira.security.roles.ProjectRoleManager def…
-
Glad to help. Just be careful with getCustomFieldObjectsByName and getCustomFieldObjectByName (one has objectS). The singular one is deprecated as of Jira 8 and the other will return an array of customfields. So you may need to look for item 0 in the list. Or else, use getCustomFieldObject(Long customFieldId) to be…
-
Ah, I see. You are right. The view screen only shows the Issue Key. And when you open the edit screen again, the dropdown shows only the issue key. This is not surprising because the database only stores the key in that text field. I think that's how it's designed to work. You could make a feature request/suggestion with…
-
The "throw new InvalidInputException" will interrupt the code so you can only throw one. So either throw it without specifying the field (and then the error message will be at the top of the form), or you duplicate your code and have 2 separate validators. You can still look at the values for both fields to determine which…
-
What you are describing is the default behavior using the example in the documentation. To help you further, it would help to see your exact code. This is what it looks like in my test:
-
In order to have the behavior script "kick in" when you change to other issue types or projects, you will need to use all issue types and all projects in the behavior mapping. Then, in your script, check the issueContext.project.key and issueContext.issueType.name and then populate with your default when they match and…
-
Here is something to get you started import com.atlassian.jira.component.ComponentAccessor def customFieldManager = ComponentAccessor.customFieldManager def correctField = customFieldManager.getCustomFieldObjectsByName('Correct')[0] def incorrectField = customFieldManager.getCustomFieldObjectsByName('Incorrect')[0]…
-
From the documentation import com.onresolve.scriptrunner.db.DatabaseUtil DatabaseUtil.withSql('local') { sql -> sql.rows('select * from project') }
-
This line does an implicit collection of all the "full_name" from all the items (that's what the * does). def repoNames = repos["items"]*."full_name" So instead, just do your own collection: def repoNames = repos["items"].collect{"${it."full_name"} ${it."node_id"}"}
-
This will depend on the target system you are trying to connect. They may have different ways of accepting un/pw. If it's basic authentication then something like this may work: import groovyx.net.http.ContentType import groovyx.net.http.HTTPBuilder import groovyx.net.http.Method def url ="the url of the system your want…
-
See this reference: https://scriptrunner.adaptavist.com/latest/jira/#_script_roots Then in behavior, this section will be relevant: https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html#_live_editing This new feature (I haven't used it yet) may also help you.…
-
The starting point for relative paths is your jira install/bin directory. You can confirm by running this in the console: <span>def currentDir </span><span>=</span> <span>new</span> <span>File</span><span>(</span><span>"."</span><span>).</span><span>getAbsolutePath</span><span>()</span> So if you want to output somewhere…
-
Seems like you would need the same script on all 3 fields so that changing each field triggers a recalculation of your priority. The best way to achieve that would be to store a script in your script root and point to the script from each server-side script for each field in the behavior. This way, you only have 1 piece of…
-
A checkbox returns a list of selected options. You'll need to compare that list of selected (checked) options against the list of available options for that field in the current context. This should work in a simple scripted validator (in your workflow) import com.atlassian.jira.component.ComponentAccessor //for this…
-
The user in issueService.validateAssign and issueService.assign is the user performing the action. The 3rd argument in validateAssign (String assignee) is the assignee you wish to apply. Try this instead import com.atlassian.jira.component.ComponentAccessor import org.apache.log4j.Logger import org.apache.log4j.Level…
-
I do something like this: import com.onresolve.scriptrunner.db.DatabaseUtil def rows = DatabaseUtil.withSql('iTrackDB') { sql -> sql.rows('SELECT TOP 5 [ID],[user_name] FROM <tablename>') } def sqlTable = new StringBuffer() //make a header row from the set of keys sqlTable << """<table class="aui"><tr>""" rows…