Comments
-
Here is an example with hardcoded approvers: import com.onresolve.jira.groovy.user.FieldBehaviours import groovy.transform.BaseScript import com.onresolve.scriptrunner.runner.customisers.WithPlugin import com.onresolve.scriptrunner.runner.customisers.PluginModule import…
-
For one thing, unless that has changed in recent versions of scriptrunner, oSystem.value will return the object Key for the selected object. You may need to use the objectFaced to retrieve an actual ObjectBean. Then you can look at the Label. The other possible problem is that multi-user pickers expect an array of…
-
Hi Kelvin That's a fairly basic use case. def fieldA = getFieldByName('User Picker A') def fieldB = getFieldByName('User Picker B') def currentField = getFieldById(fieldChanged) fieldA.clearError() fieldB.clearError() if(fieldA.value == fieldB.value){ currentField.setError("Please select a different user.…
-
That's a server script. The line: import com.atlassian.jira.component.ComponentAccessor Is the first giveaway. These are java classes for the java API which is not available in the cloud.
-
Correct, if you don't care what the user enters and you just want to overwrite it, you could just use: import com.atlassian.jira.component.ComponentAccessor def versionManager = ComponentAccessor.versionManager def version = event.version def descriptionTemplate = 'Approver: _____ Tester: _____ '…
-
Hi Andrew I was there.... and unless I missed it, there wasn't a single mention of "data center" in any of the keynotes or any of the Atlassian-led breakout sessions. All the shiny new stuff is cloud-only. They did have an "Enterprise Migration" booth where they showed the 2 options: cloud or dc. But I didn't get around to…
-
Ah, sorry, my fault. I forgot to include an import. Add import groovy.time.TimeCategory
-
Hover over the underlined text and it will tell you. Perhaps the field name is incorrectly spelled for the first field. Then the comparison can't be confirmed to be correct since the code checker doesn't know what value will be returned from a field that it doesn't recognize.
-
A user could belong to more than one organization. This script will give you all organization ids: import com.atlassian.jira.component.ComponentAccessor import com.atlassian.servicedesk.api.organization.OrganizationService import com.onresolve.scriptrunner.runner.customisers.PluginModule import…
-
If you want to do this in a Workflow Validator (as implied by your tags), you can easily do this with a simple scripted validator. def date1 = cfValues['DA Onay Tarihi'] def date2 = cfValues['Hedeflenen Tamamlanma Tarihi'] date2 >= date1 When the simple scripted validator returns true, then nothing happens. When it returns…
-
Where are you trying to do this? In a listener, post function or in a behaviour? In a behaviour, you could have the data automatically populated on-screen and either give the user the option to change it or lock the field as read-only. But since you called the updateIssue manually, I'll assume you are trying to do this in…
-
The event variable that will be available within the context of your event listener when listening for Version Create Event will be of type VersionCreateEvent. And one of the available method for that class are "getVersion" and getVersionId. So in your groovy script, you can call event.version.id or event.versionId You…
-
Try to call your script both in AJS.$(document).ready() function but also in AJS.$(document).ajaxComplete(). The first one runs when you first access the page, the second will run each time more data is fetched from the server.
-
So, you have 3 fields that should be visible or not based on a specific value in a multi-select list being selected or not. Here is how I would write this: def multiSelectFieldName = 'Resource Type for Application' def multiSelectField = getFieldByName(multiSelectFieldName) def selectedValues = multiSelectField.value as…
-
I found that an interesting little challenge and I whipped this up: import com.atlassian.jira.bc.issue.search.SearchService import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.web.bean.PagerFilter def searchService = ComponentAccessor.getComponent(SearchService) def changeHistoryManager =…
-
The code I suggested was for a listener that was configured to listen to the "Issue Updated" event (so you can detect when an issue is assigned to a sprint). If you are attempting to listen to the "Sprint Updated" event, the following line won't work: def event = event as IssueEvent Neither will def issue = event.issue…
-
issue.components*.name will give you a list of component names associated with the issue.
-
"Behaviour" code is always inherently different from most other code in Scriptrunner (listener, post function etc) because it is designed to interact with the screen DOM elements. Whereas all other Scriptrunner script are designed to run at the server level on java objects. So "getFieldById" is a behaviour method to get a…
-
In your project, under issue security, select "Edit Issue Security" under the "Actions" menu. Then, hover over the actions for the security level for which you want to know the ID. In the URL, you will see something like: &levelId=10230&schemeId=10330 The level id is 10230. If you want to get it using scriptrunner console:…
-
It's not that complicated, it was just a switch from your initial description. Here is a short Custom Post Function script that should achieve what you described: import com.atlassian.jira.component.ComponentAccessor import com.onresolve.scriptrunner.runner.customisers.WithPlugin import…
-
Simple Script Condition shouldn't change anything on the issue. They should only be used to determine if the transition button should be displayed when viewing the issue. If you are trying to change the reporter in a Post Function, then that's a whole other scenario. There is no built-in function that sets the assignee as…
-
Select List custom field return an "Option" object. So in the script, you need to compare that option's "value" attribute against an expected string. Try cfValues['Affected Business Service'].any{it.label == 'Billing Service'} && cfValues["Related Section"].value == "Accounting" When the line becomes too long if you have…
-
Based on the list of available validators in your screenshot, it looks like you have a fairly vanilla instance of Jira Service Management. A lot of the more advanced features of Jira workflows are provided by third-party apps from the marketplace. Unfortunately, the good ones are not going to be free. The three most…
-
You should be able to do that with a Custom Script postfunction on your create transition. Here is a sample script: import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.security.IssueSecurityLevelManager def issueSecurityLevelManager =…
-
The simplest approach would be to use the following: cfValues['Affected Business Service'].any{it.label == 'Billing Service'} If you just attempt to compare the cfValues as if it was a plain string, it would look like [Billing Service (KEY-123] where key-123 is the key for your billing service object. That is because the…
-
In a simple scripted condition, the cfValues['Affected Business Service'] will return an array of ObjectBean. This is true whether or not the custom field allows multiple. But not when the fied is empty. This is how I generally get those values so that I consistently have the right kind of data: def values =…
-
I had assumed that your date field was a date/time picker. So change def dateTimeFormat = 'dd/MMM/yyyy hh:mm:ss' to def dateTimeFormat = 'dd/MMM/yyyy' And I always make the mistake between username and userkey, I never know which API works with which. Change iip.addCustomFieldValue(cf4.idAsLong, currentUser.key) To…
-
Try assert validationResult.isValid() : validationResult.errorCollection This should give you some details about why the validation was not valid. What type of field are each of your custom fields?
-
As I said before I don't have access to a cloud instance to test or debug this further. You'll have to refer to the GitHub api documentation and the scriptrunner/unirest documentation. You can try to change asObject() to asString(). But the 422 error likely means that github has some problem with the payload. I'm affraid I…
-
I'm not aware of a change in SR or Jira that would account for what you are describing. I don't think that "now" has ever been a valid keyword in groovy. Unless some older version of scriptrunner included this as a built-in variable. But I'm not sure why it would have, this is hardly a shortcut for the normal "new Date()"…