Hi i have a listener in Groovy. It's check a value of labels and if labels value is not 'form_email', then script set a predefined value of another custom field. The problem is when I create issue by email. JEMH set labels value on 'from_email', but script still set value of custom field. I don't know where is a problem. Here is my code.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.label.LabelManager
import com.atlassian.jira.issue.util.IssueChangeHolder;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
def issue = event.getIssue()
def projName = issue.projectObject.name
def label = issue.labels
def labelMgr = ComponentAccessor.getComponent(LabelManager)
def containsLabel = "from_email" in issue.getLabels()*.label
def CFM = ComponentAccessor.getCustomFieldManager()
def crmContacts = CFM.getCustomFieldObjectByName("CRM Contacts")
if (!containsLabel)
{
switch (projName){
case 'PROJ1':
Issue myIssue = event.getIssue()
def changeHolder = new DefaultIssueChangeHolder();
crmContacts.updateValue(null, myIssue, new ModifiedValue(myIssue.getCustomFieldValue(crmContacts), '(356,)'), changeHolder);
myIssue.store()
break;
case 'PROJ2':
Issue myIssue = event.getIssue()
def changeHolder = new DefaultIssueChangeHolder();
crmContacts.updateValue(null, myIssue, new ModifiedValue(myIssue.getCustomFieldValue(crmContacts), '(10)'), changeHolder);
myIssue.store()
break;
}
}
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.