Comments
-
Both com.microsoft.sqlserver.jdbc.SQLServerDriver and net.sourceforge.jtds.jdbc.Driver normally come bundled with Jira. The only driver I've ever had to install is the mysql driver, and that's done at install since that's what I use for my jiradb. Looks like your attempt using 'com.microsoft.sqlserver.jdbc.SQLServerDriver'…
-
Ah ok, this is the method you are calling https://docs.oracle.com/javase/7/docs/api/javax/naming/directory/DirContext.html#getAttributes(java.lang.String) I was able to get it to work without the static type checking errors by doing this: def results =…
-
Try not using Global=True in your context builder. This means all projects. Also, selecting fieldConfigSchemes[0] won't be reliable when you have more than 1.
-
def lclsum if(fieldValues.any{it == null}){ log.warn "Found at least one null value in $fieldValues" lclsum = 'null' } else { lclsum = fieldValues.sum() as String }
-
That's normal. a null value shows a blank/empty in forms. If you want to show the actual word null, then you must set the text value to 'null' as opposed to the logical null value
-
Ah... now we're getting somewhere. So, the issue is with "isInteger() " ... it says false, because the numbers are double. So le'ts keep the values as double and sum them that way. log.debug "Found $val in $fieldName, attempting to convert to number: ${val?.isNumber()}" (val?.isNumber()) ? val.toDouble() : null And because…
-
We can try to force the logging level and add some additional log messages: import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.util.DefaultIssueChangeHolder import com.atlassian.jira.issue.ModifiedValue def im = ComponentAccessor.getIssueManager() def cfm =…
-
Did you look at the logs when you executed the preview? I had not been trying to test the code base those fields were no applicable in my environment, but to finally get to the bottom of it, I actually implemented it in my dev environment, and saw this in the log tab: 2020-05-28 10:39:47,217 ERROR…
-
I forgot to include the imports necessary to support the customfield update import com.atlassian.jira.issue.util.DefaultIssueChangeHolder import com.atlassian.jira.issue.ModifiedValue And I had a typo in the last line. It should be "return" not "returm". But if you want to use a listener as I suggested, this is what you…
-
That is such a great question and wonderfully stated too. I wish I had had the answer when I got started. I am not aware of any good scriptrunner development bible or reference. After a few years of scriptrunner/groovy hacking, I'm probably at the point where you wish you were. But I got there the same way you are...…
-
Maybe you can try it on a single issue in the console and try to narrow down the source of the issue. For example, I took the script I suggested and pared it down to just the transition piece and added a manual issue definition (and added a statu/transition map item that matches my workflow): import…
-
Sorry, I don't know what you mean. Can you give more details?
-
Yeah, I have some of those conversions to do in my own environment. I hope what I've shared will point you in the correct direction.
-
I don't understand why you would choose to use 2 fields that way, but yeah, if you want to update a second field during the calculation of a scripted field, you can do that. I would warn that this may not be very efficient in the long run. A scripted field is re-calculated upon each issue view (and during indexing). This…
-
Can you show the full screen of the scripted field? There is something that doesn't quite jive. A scripted field is not normally visible on the edit screen, it gets calculated live in the view screen and every time the issue is updated. It can never be edited by the user. I suspect you have another field (perhaps with the…
-
I was making an assumption that these fields were "number fields". Looks like they are text, and as such, they could contain "", " ", "ABC", "123" etc So you need to protect for that: import com.atlassian.jira.component.ComponentAccessor def im = ComponentAccessor.getIssueManager() def cfm =…
-
Did you try to run it with Preview? The "Static Type checking" error can often be ignored. This just means that the code editor cannot confirm that the "toInteger() will work. But if that really bothers you, you can change it to return fieldValues.sum{it as Integer}
-
How about compressing this to just a few lines like this: import com.atlassian.jira.component.ComponentAccessor def im = ComponentAccessor.getIssueManager() def cfm = ComponentAccessor.getCustomFieldManager() def fieldsToSum = ['LCL RG Points','LCL Wi-Fi Points','LCL RG Auto Points','LCL Wi-Fi Auto Points'] def fieldValues…
-
It's enabled by default in newer versions. Usually, after upgrading, the console will have a large announcement panel that shows he shortcuts. You can find the details here: https://scriptrunner.adaptavist.com/latest/jira/code-editor.html
-
There is no public documentation for this, but all their canned scripts pretty much follow the same template. The doscript params is a map of FIELD : value. You can get the list of fields using the scriptrunner console's autocomplete. To answer your other question, I've never seen a cloning feature in jira (built-in or add…
-
I can't share any code without specific goals... but I can point you to the correct apis https://docs.atlassian.com/software/jira/docs/api/8.5.1/com/atlassian/jira/issue/fields/config/manager/FieldConfigSchemeManager.html and…
-
I like to use reggex101 for figuring this out: https://regex101.com/r/BF2fSf/1 Then using scriptrunner, you put it together using groovy matcher def input = 'kloc/a6bb4232-f1c5-40fc-99d5-004046ff249d,10002,10430,false' def matcher = input =~ /.*\/(.*?),/ def result = (matcher) ? matcher[0][1] : null
-
I don't know if it's possible to change the history. You can definitely read the history. There is a method to clear the history. And you can add to the history using the ChangeLogUtils. But there is no updateChangeItem method to store/persist the ChangeItemBean that you've attempted to modify. At best, you can retrieve a…
-
See https://docs.atlassian.com/software/jira/docs/api/8.5.1/com/atlassian/jira/issue/CustomFieldManager.html#getCustomFieldObject-java.lang.Long- Try either def cField = customFieldManager.getCustomFieldObject(10301) Or def cField = customFieldManager.getCustomFieldObject("customfield_10301")
-
Glad it helped. I rarely bother with static typing. The "static type check" errors can often be ignored. Please remember to accept the answer if it helped you. "Solved" questions are easier for others to find.
-
If you set up the user correctly in the Job configuration, you don't need to use setLoggedInUser, scriptrunner will take care of that for you
-
I think the fundamental issue you are seeing is with the selection of the user field in the escalation service configuration, not in the code. Try to re-select the user you want the job to run as. Regarding your labels question, where is this used? Can you elaborate, your question is confusing? You are asking about labels,…
-
Can you share the full code (just remove/hide passwords or other binding/private information)? What you seem to be telling me is that getAttributes("") works, returns the values you expect, but you don't like the static code checking error in the editor. But when you remove the doubleQuotes, the static code checking errors…
-
Perhaps some more detail as to where this code is implemented exactly. This code seems incomplete. For example: * where is "customField" defined from the line "def value = issue.getCustomFieldValue(customField)" * What are you expecting "MutableIssue mutableIssue = (MutableIssue)" to do? There is no data to put into the…
-
"Static type checking" errors are often safe to ignore. It just means the code editor is unable to confirm the class of an object, so it can't be sure what methods are allowed. The important information is what you get in the logs when you actually try to run the script. Other than a small error in how issue was being…