this is my scprit:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
def price = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("price"))
def num = issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("num")
if (price) {
return price * num)
}
else {
return null
}
The field values you are pulling back are objects, not simple numbers. You need to convert the contents to numbers before you can multiply them together (and bear in mind they might be nulls too, which you'll want to capture and handle)
Look at the error message you showed in your original before you changed the question - the error was saying that the calls to get the field data had returned an object, not a number.
So yes, you need to convert the objects returned into numbers. (Trying to multiply objects tends not work - yes the objects you get from the fields might be "4" and "5", but they might also be "banana" and "apple", and there's no way to know what you might want from multiplying those together)
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.