Hi,
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>
Hey,
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.
https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner
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:
https://marketplace.atlassian.com/plugins/com.innovalog.jmwe.jira-misc-workflow-extensions
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":
https://innovalog.atlassian.net/wiki/display/JMWE/Post-functions#Post-functions-4-IncreasevalueoffieldFunction
Cheers
Christian
Exactly what Christian said. If you don't need to use the behaviours plugin and you can do everything server-side, then do it. Use behaviours when you want dynamic form behaviour, or you want the user to be able to override the suggestion.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Christain, I used script runner plugin for this and it worked
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi When you are updating the custom field is it for that particular ticket or for ever for that project.
I even need to decrease the custom field value but next when anyone logs in he should see the decreased value. How can I achieve it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Projects don't have fields, so it's for the issue.
When a value is changed via a script or behaviour, you will see it the next time you land on or refresh a page
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic,
Can you guide me how can I achieve it. I was using javascript to add a value in the custom field but when I refresh the page the custom field does not have that value. It contains only for that issue. How can I change the value in the custom field so that it exists even after refresh. Kindly guide me to achieve it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I wouldn't do it with Javascript, that way madness lies. Use a proper field and a bit of code to change the value.
What do you have in the way of scripting add-ons?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.