I have customn field that I would like to set to the component lead if chosen and if not to the project lead. I have used a script as post function to realize this on issue creation, but it does not do anything 
This is the code:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import com.atlassian.jira.issue.util.IssueChangeHolder;
import com.atlassian.jira.user.ApplicationUser;
// GOAL: assign all user ids of the current issue components' lead to the custom field 'Additional assignee'
Issue issue = issue; // Not really needed but it will save you some red underlining when creating the listener
CustomField additionalAssigneeField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName("Additional Assignee(s)")[0];
//for every component that it is linked to the current issue
for (int i = 0; i < issue.getComponentObjects().size() ; ++i)
{
// 1-Get the issue's component's lead
// 1.1- get the component of the current issue
ApplicationUser componentLead = issue.getComponentObjects()[i].getComponentLead(); // returns an ApplicationUser
// 1.2- get the lead id of the component
String componentLeadId = componentLead.getKey();
// 2-Assign it to the issue's custom field
// 2.1- Prepare the ModifiedValue pair
List oldValue = issue.getCustomFieldValue(additionalAssigneeField) as List;
List newValue = oldValue;
ModifiedValue modifiedValue = new ModifiedValue(oldValue, newValue);
newValue.add(ComponentAccessor.getUserUtil().getUserByKey(componentLeadId));
// 2.2- Create a ChangeHolder
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
// 2.3- Update the value in database
additionalAssigneeField.updateValue(null, issue, modifiedValue, changeHolder);
}
return true;What did I do wrong here?