Comments
-
You bet it is! This can be done with a Behaviour. Create a behaviour on the Assignee field with a validation script like the one below: import com.atlassian.jira.component.ComponentAccessorimport com.onresolve.jira.groovy.user.FieldBehavioursimport groovy.transform.BaseScript@BaseScript FieldBehaviours fieldBehavioursdef…
-
Aha! The helper variable in the binding is only available in 4.1.3.17 and beyond. For JIRA 7 users, you'll want to use 4.3.7 and beyond. https://scriptrunner.adaptavist.com/4.1.3.17/jira/builtin-scripts.html#_send_a_custom_email This was part of the rewrite of the Send Custom Email postfunction we did back in July to add…
-
I'm investigating this now. I've noticed that in the version-specific documentation, we don't mention the helper: https://scriptrunner.adaptavist.com/4.1.3.15/jira/builtin-scripts.html#_send_a_custom_email I'd hazard that's deliberate. It well may be that this only works in JIRA 7.
-
So, here's the script as it will appear in the next published set of docs: import com.atlassian.jira.component.ComponentAccessorimport com.onresolve.scriptrunner.runner.ScriptRunnerImplimport com.onresolve.scriptrunner.runner.customisers.PluginModuleimport com.onresolve.scriptrunner.runner.customisers.WithPluginimport…
-
Did you see my note about Tempo 7 and 8? What version are you using? That may be the source of your issue. If you're not sure why the script is failing to log time, but running. I'd recommend adding a few log.debug statements. You should be able to see the output of the runs of your post function in the Workflow…
-
Is the static type checking error showing up in the input field in JIRA? That may not actually be an issue. The static type checker will err conservatively, meaning that sometimes a script that would work will be listed as having static type checking errors. More advanced scripts like this one are better analyzed using an…
-
The com.atlassian.sal.api.component.ComponentLocator class may actually be the nearer equivalent.
-
There is a built-in method and example for this in Simple Scripted Validator. isUserMemberOfRole('Lead Software Developer')
-
I think my original example was unclear. I've updated it to more clearly show what I mean. It's only "one-off" in the sense that you'd run it once via the Script Console. It should update all 183k issues (though you might do a test batch first with a very selective JQL query, just to make sure it works as you expect).
-
So, updating an issue without affecting the issue history is not well supported by the API. That said, for a one-off mass-update, you could write a script for the Script Console that did the update. You'd want to get the results of a JQL query, then edit each item in the list. This fairly naive example demonstrates how…
-
For comparing equality, Groovy makes strings easy: import com.atlassian.jira.component.ComponentAccessordef issue = ComponentAccessor.getIssueManager().getIssueObject(link) if( issue.status.name == "Eng Assign"){ do some thing here }else{ do dome other logic here } Both .equals and the == operators will return a boolean…
-
That makes more sense... I just sort of assumed the "if" condition was the one you wanted, and didn't look too closely! I've updated my answer.
-
Instead of putting the script in the initializer, I'd put it in a server-side script on the Issue Type field. To remove your added text whenever someone switches to/from the issue type, the best thing to do would be to get the currently input value and just use a .replaceAll to remove the example text. You can limit this…
-
What if your macro parameter just took a task ID (or list of task IDs) as a parameter? You could also provide the number of days to add/subtract as a parametr. Then it would lay out the table for you based on the task dates. Since the WorkBox is a plugin, you'll need the @WithPlugin and @PluginModule annotations. import…
-
How does the template know which tasks to look at? Are they always new tasks?
-
I'm a little unclear on how your template takes information about existing tasks and creates the table of dates and such. That's the critical point, as that's where you might capture the task object's ID. From your script, it looks like you're assuming that the task table is already present in the macro body, which I…
-
There are several ways you might approach the problem. If you're happier sending some subset of the attachments that gets below the threshold, then you could use the email post function's custom callback field to determine which attachments get included, and which don't. For example, let's say you wanted to send the…
-
There is a REST Endpoint ( rest/scriptrunner-jira/latest/jqlfunctions/aggregateResult ) built into ScriptRunner that returns the results of the aggregateExpression function. You could send a GET request to it by fetching the a URL like the following, where the jql query parameter is a URL encoded JQL statment using…
-
issue.getCustomFieldValue is the method you're after. Using it in the link there is likely to be a bit unwieldy, but it should be possible inside of closure braces. issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).find{it.name == "My Custom Field"})…
-
Yeah, it's definitely stripping out all the HTML tags, even when the field is configured to output HTML. Not sure if that's something JIRA changed with the advent of JIRA Software to replace/update JIRA Agile?
-
There are some things I don't get about your script. PlannedBudget is an int, but you're calling .round() on it. Also, you've got PlanedBudget at the declaration point, then PlannedBudget everywhere else. I was able to get your script working in JIRA 7 with SR 4.3.5. Let me try switching back to your version of JIRA.
-
Could you show some of the code for your scripted field? Particularly the HTML it is supposed to output.
-
That's pretty normal, in my experience. IssueService is, by its own description, better suited to making sure all the magic happens. This services methods will make sure that when dealing with Issue's that all of JIRA's business rules are enforced. This means that permissions and data validation will be checked, proper…
-
So, you could do a check to see whether the custom field has actually changed, as well as checking whether Fix Version is empty. def cusField = getFieldById(getFieldChanged())def fix = getFieldByName("Fix Version/s")def fixVersionEmpty = (fix.getValue() == null) || (fix.getValue() == "")def customFieldChanged =…
-
I can't find the class com.atlassian.greenhopper.features.JiraSoftwareFeature, even in the JIRA Software source. I can find a JiraAgileFeatures class in the same package in the API docs (https://docs.atlassian.com/jira-software/6.7.12/com/atlassian/greenhopper/features/package-summary.html), but I'm not sure that's what…
-
Think you could include the whole code block, imports and all?
-
If you're using JIRA's export-to-excel feature from an issue filter, no. The value of the field, at that point, is what it is. You could maybe change the output of the field to be a comma-separated list of values, instead of a sum. It sounds like the example script doesn't actually return what you want, and you need to…
-
It is possible to interact with Tempo via a scripted field. Take a look at our documentation on working with Tempo. The currently published guide is written for Tempo 7, but the next release of ScriptRunner should include documentation for working with Tempo 8 on the same page. It can be difficult to engineer certain…
-
A validator will work for workflow steps, but that will only apply to changes that take place during a workflow transaction. If you want to guide edits to the issue as well, you will need to use a behaviour. If Vasiliy's code isn't working, I'd recommend you try extending the FieldBehaviours class using the BaseScript…
-
Pass the field name to the exception constructor as an argument. From the docs: throw new InvalidInputException("myField", "UR DOIN IT RONG") The general messages are those without a field parameter specified: throw new InvalidInputException("UR DOIN IT RONG IN A MOAR GENERAL WHEY")