All the values of these custom fields must be appear in the fourth custom field before creating the issue.
Ex : user enter the value in custom field A is 1
B is 2
C is 3
1+2+3-->6
Final value is appear in fourth custom field before creating the issue...(6)
Can you guys are help me out this issue for how to do in groovy scripting.
You need to get the custom field IDs first, you can get this by editing the custom field configuration, the ID will be shown in your browser URL. Once you have the custom field IDs, you can create a script for your 4th field with something like this:
fieldA = issue.get("customfield_xxx");
fieldB = issue.get("customfield_yyy");
fieldC = issue.get("customfield_zzz");
return fieldA + fieldB + fieldC;
Substitute the xxx, yyy and zzz for your specific custom field IDs. If you want to protect against null values, you can do this:
fieldA = issue.get("customfield_xxx") != null ? issue.get("customfield_xxx") : "0";
fieldB = issue.get("customfield_yyy") != null ? issue.get("customfield_yyy") : "0";
fieldC = issue.get("customfield_zzz") != null ? issue.get("customfield_zzz") : "0";
return fieldA + fieldB + fieldC;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Pete Singleton Thanks For your Response. i am trying to execute the code you are given but it shows some error
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Which plugin are you using to execute the script? Can you post the entire script you are using?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
def cfM = ComponentAccessor.getCustomFieldManager()
def QuantityOnHoldCF = cfMan.getCustomFieldObject("customfield_11518");
int QuantityOnHoldCFValue = (int) issue.getCustomFieldValue(QuantityOnHoldCF);
def quaCF = cfMan.getCustomFieldObject("customfield_11519");
int quaCFValue = (int) issue.getCustomFieldValue(quaCF);
def abcCF = cfMan.getCustomFieldObject("customfield_11517");
int abcCFValue = (int) issue.getCustomFieldValue(abcCF);
return QuantityOnHoldCFValue + quaCFValue + abcCFValue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It seems ComponentManager has been deprecated with Jira 8. Just remove that line (3) and it should work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
def cfM = ComponentAccessor.getCustomFieldManager()
def QuantityOnHoldCF = cfM.getCustomFieldObject("customfield_11518");
int QuantityOnHoldCFValue = (int) issue.getCustomFieldValue(QuantityOnHoldCF);
def quaCF = cfMan.getCustomFieldObject("customfield_11519");
int quaCFValue = (int) issue.getCustomFieldValue(quaCF);
def abcCF = cfMan.getCustomFieldObject("customfield_11517");
int abcCFValue = (int) issue.getCustomFieldValue(abcCF);
return QuantityOnHoldCFValue + quaCFValue + abcCFValue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried the code I posted??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I've just tested the script below using my instance and ScriptRunner, it works. You will need to change the custom field IDs to the correct ones for your instance:
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.component.ComponentAccessor;
def cfM = ComponentAccessor.getCustomFieldManager()
def QuantityOnHoldCF = cfM.getCustomFieldObject("customfield_10301");
int QuantityOnHoldCFValue = (int) issue.getCustomFieldValue(QuantityOnHoldCF);
def quaCF = cfM.getCustomFieldObject("customfield_10302");
int quaCFValue = (int) issue.getCustomFieldValue(quaCF);
def abcCF = cfM.getCustomFieldObject("customfield_10303");
int abcCFValue = (int) issue.getCustomFieldValue(abcCF);
return QuantityOnHoldCFValue + quaCFValue + abcCFValue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.