set number field based on a selected field

Louisa Pabst July 22, 2015

 Hi,

I want to set a number field by selecting another field. The custom field "Category" is a select list (single choice), the custom fields "Weight Order" and "Weight Project" are number fields with a default value and the custom field "Customfield" is a number field.

def category = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Category")).getValue();
if(category == "Order"){
def weight = issue.getCustomFieldValue(ComponentAccessor.getcustomFieldManager().getCustomFieldObjectByName("Weight Order"));
}
if(category == "Project"){
def weight = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Weight Project"));
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Customfield");
issue.setCustomFieldValue(cf, weight);

 Best Regards,

Louisa

1 answer

0 votes
Louisa Pabst July 22, 2015

The custom field "Category" is a multiple choice select list!

Suggest an answer

Log in or Sign up to answer