In custom field, can we add below evalutaion condition ?
if 55 < TotalCustomField1 < 80 = 1.5
If 30 < TotalCustomField1 < 55 = 3.5
If TotalCustomField1 < 30 = 4
i went through below link, but i could not found as above how i want:
Can we add as below in custom field ?
if((issue.get("customfield_11246") != null ? Integer.parseInt(issue.get("customfield_11246")) : 0) >55 && (issue.get("customfield_11246") != null ? Integer.parseInt(issue.get("customfield_11246")) <80)
{
return 1.5
}
or any alternative solution ?
You can also use the free Script Runner plugin and create a scripted custom field with code like yours above.
Henning
can you please correct me if below stuff not work direclty .. then how to fetch custom field value in groovy script runner and based on it's value return the value as above comment example.
if((issue.get("customfield_11246") != null ? Integer.parseInt(issue.get("customfield_11246")) : 0) >55 && (issue.get("customfield_11246") != null ? Integer.parseInt(issue.get("customfield_11246")) <80) { return 1.5 }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What kind of field is your customfield?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If it's a text custom field, this should work.
def user = componentManager.jiraAuthenticationContext.getLoggedInUser() Double ret = null if (componentManager.fieldManager.getAvailableCustomFields(user, issue).find{it.name == 'Custom Field Name'}) { try { int value = (getCustomFieldValue('Custom Field Name') as String)?.toInteger() } catch (NumberFormatException nfe) { value = 0 } switch (value){ case {it < 30}: ret = 4.0; break case {it < 55}: ret = 3.5; break case {it < 88}: ret = 1.5; break default: ret = 0.0 } } return ret
Please be aware to choose the matching number templates.
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Henning.
actually, this script field is not appearing in the screen where asscoiated.
it shows in "where is my field" when i do it on edit screen but not appear in the screen. what can be the cause..
jira stand alone version - 5.2.11
my custom field type (whose value in evalutaion) is "calcualted custom field"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Scripted fields will only be displayed on the view screen because they are not editable.
I don't know which kind of object the customfield value of a "calculated custom field" is. If the script throws exceptions you may hav to look at the class of the return value from getCustomFieldValue().
log.error getCustomFieldValue('Custom Field Name')?.class?.name
print the class name of the object to the log file.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, this would work, assuming the two customfields are text fields or equivalent. If the customfields are numeric fields, you don't need to parse them, and if they are select fields, you'll need to add a getValue() on the result of the get().
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
when i paste above stuff then unable to see the field in screen..
yes, value is from calculation textbox field only (used in 'if' condition).
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.