I am using behaviour plugin to update value of a custom field everytime a issue is reopened.. I am using the below code but no luck!!..Can anyone pls help
<config use-validator-plugin="false" name="Reopen Counter behaviour" description="" guideWorkflow="Test"> <field id="customfield_12051" required="null" readonly="false" hidden="false" validator-class="" validator-script="import com.onresolve.jira.groovy.user.FormField&#13;&#10;&#13;&#10;FormField formUserField = getFieldByName(&quot;ReopenCounter&quot;)&#13;&#10;&#13;&#10;formUserField.setFormValue(Integer.valueOf(formUserField.getFormValue()) + 1)&#13;&#10;" validator-method=""> <when action="3"/> </field> </config>
I know that this isn't really answering your question but I think you're better off using for example the script runner to inject a script which is increasing the field value by one as a post-function.
You don't need to update the field in real-time and that's the benefit of the behaviours plugin...
You could also think of the Misc Workflow Extensions Addon:
I know that it's not free anymore but if offers all kinds of useful post-functions such as "increasing the value of a field":
Issue issue = issue String field = "customfield_12250" CustomFieldManager customFieldManager = componentManager.getCustomFieldManager() CustomField fieldobj = customFieldManager.getCustomFieldObject(field) counter = issue.getCustomFieldValue(fieldobj).floatValue() counter+=1 issue.setCustomFieldValue(fieldobj, counter)
Some minor updates to Bhupesh's code above, updating it for v6.2.7, and possibly higher:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.fields.CustomField MutableIssue issue = issue CustomField fieldobj = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("myFieldName") counter = (float) issue.getCustomFieldValue(fieldobj) counter+=1 issue.setCustomFieldValue(fieldobj, counter)
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot