I would like to try the Behaviours add-on to copy value from a text field from epic to story. We have a script for post function but some workflows are to big and it makes the maintenance awkward.
We are using:
our script for post function:
importcom.atlassian.jira.issue.Issue;importcom.atlassian.jira.ComponentManager;importcom.atlassian.jira.issue.CustomFieldManager;importcom.atlassian.jira.issue.fields.CustomField;importcom.atlassian.jira.component.ComponentAccessor;importcom.atlassian.jira.issue.managers.DefaultIssueManager;importcom.atlassian.jira.issue.IssueManager;CustomFieldManager cfm = ComponentAccessor.getCustomFieldManager()CustomField el = cfm.getCustomFieldObject('customfield_11571')CustomField cpi = cfm.getCustomFieldObject('customfield_11095')IssueManager im = ComponentAccessor.getIssueManager()issue.setCustomFieldValue(cpi, im.getIssueByCurrentKey((String)issue.getCustomFieldValue(el)).getCustomFieldValue(cpi))
I tried to use the script from CGM, but I get an error message:
Can you help me?
Best regards,
Tatiana
Hi @Alex Kulichkov ,
please try something like this (just replace the constants with your custom field ids):
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
Long CUSTOM_FIELD_ID_1 = 10359L
Long CUSTOM_FIELD_ID_2 = 10400L
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField customField1 = customFieldManager.getCustomFieldObject(CUSTOM_FIELD_ID_1)
CustomField customField2 = customFieldManager.getCustomFieldObject(CUSTOM_FIELD_ID_2)
Float number1 = issue.getCustomFieldValue(customField1) as Float
Float number2 = issue.getCustomFieldValue(customField2) as Float
return (number1 && number2) ? number2 / number1 * 100 : 0
Hi @Hana Kučerová,
Thank you very much, it worked perfectly! Great script example for all simple % based calculations.
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.