Hi,
i have 6 custom fields. On saving an issue i want to store the sum of this fields as timetracking original estimate.
I add an behavior with following code in init:
def field = getFieldById('timetracking_originalestimate');
def fe_1 = getFieldById('customfield_12722').getValue();
def fe_2 = getFieldById('customfield_12723').getValue();
def fe_3 = getFieldById('customfield_12724').getValue();
def be_1 = getFieldById('customfield_12725').getValue();
def be_2 = getFieldById('customfield_12726').getValue();
def be_3 = getFieldById('customfield_12727').getValue();
field.setFormValue(Math.round((Double.parseDouble((String) fe_1) + Double.parseDouble((String) fe_2) + Double.parseDouble((String) fe_3) + Double.parseDouble((String) be_1) + Double.parseDouble((String) be_2) + Double.parseDouble((String) be_3)) * 60 * 60));
Nothing happend.
Thanks for your help
Hi Thorsten,
i dont know the methods you are using but maybe this example helps you,
this is code we have in use for an event Listener that sets an custom field value:
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import java.sql.Timestamp
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.jira.event.type.EventDispatchOption
def issueTypeId = issue.getIssueTypeId()
IssueManager issueManager = ComponentAccessor.getIssueManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
ApplicationUser user = jiraAuthenticationContext.getLoggedInUser()
CustomField technikerTerminCF = customFieldManager.getCustomFieldObjectByName("Techniker-Termin")
Timestamp technikerTermin = issue.getCustomFieldValue(technikerTerminCF);
MutableIssue mutableIssue = issueManager.getIssueObject(issue.getId());
mutableIssue.setCustomFieldValue(technikerTerminCF, technikerTermin)
issueManager.updateIssue(user, mutableIssue, EventDispatchOption.ISSUE_UPDATED, false)
Cheers
Jens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.