Custom Field 1 - Impact
Not Applicable-0
Insignificant-1
Minor-2
Minor-3
Moderate-4
Moderate-5
Moderate-6
Major-7
Catastophic-8
Catastophic-9
Catastophic-10
Custom Field 2 - Likelihood
Custom Field 3 - Counter Measures
As of my understanding, these are single-select custom fields and you need to convert them into numbers based on their values: e.g. Catastophic-8 is equal to "8", then multiply all three fields and set it to a number field which is customfield4.
Is that what you want?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This might be a good starting point,
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.customFieldManager
def cf1 = customFieldManager.getCustomFieldObject(id1) // id of the CF1
def cf2 = customFieldManager.getCustomFieldObject(id2) // id of the CF2
def cf3 = customFieldManager.getCustomFieldObject(id3) // id of the CF3
def cf4 = customFieldManager.getCustomFieldObject(id4) // id of the CF4 (multiplication result)
def cf1Value = issue.getCustomFieldValue(cf1).toString()
def cf1IntValue = cf1Value.substring(cf1Value.lastIndexOf("-") + 1, cf1Value.length()) as int
def cf2Value = issue.getCustomFieldValue(cf2).toString()
def cf2IntValue = cf2Value.substring(cf2Value.lastIndexOf("-") + 1, cf2Value.length()) as int
def cf3Value = issue.getCustomFieldValue(cf3).toString()
def cf3IntValue = cf2Value.substring(cf3Value.lastIndexOf("-") + 1, cf3Value.length()) as int
int cf4Value = cf1IntValue * cf2IntValue * cf3IntValue
issue.setCustomFieldValue(cf4,cf4Value)
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.
there are some errors in the code can you look in to this and suggest changes?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can't use space characters in your variable definition.
Simply change all "Counter MeasuresValue" to "CounterMeasuresValue" , etc..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
but even our custom field has a space does it work if I write the code with out a space?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, it will work. This is just the variable name, it does not need to be the same as the custom field name.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please try this?
MutableIssue missue = (MutableIssue) issue
missue.setCustomFieldValue(RPN,RPNValue)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Don't forget to add this import statement to the top line
import com.atlassian.jira.issue.MutableIssue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No errors now but it only displays null values with out any error in log
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.
Have you checked the issue if it was updated?
Since your code does not return anything, it is normal to see null in the Result section.
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.
Is this post function? Where are you using this script?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
By the way, you can add log.error lines to see whether your calculations are OK.
log.error("ImpactIntValue: $ImpactIntValue")
log.error("LikelihoodIntValue: $LikelihoodIntValue")
etc.
You will see the logs in the Logs section
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.
Did you share a link?
Anyway, I think you are using a scripted field.
Then please skip the last line
issue.setCustomFieldValue(RPN,RPNValue)
instead, use this
return RPNValue
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.
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.
What scripting/automation apps do you have available?
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.