Get a custom field object and update its value to be displayed

In order to update a custom field’s value, please follow these stesp

  1. Get an mutable issue object
  2. Get ‘ComponentManager’ object
  3. Get ‘CustomFieldManager’ object
  4. Get an custom field object with an custom field id (like 10106)
  5. Update custome field’s value
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField

//Get an mutable issue object
MutableIssue myIssue = issue

issueKey =  myIssue.getKey()

//Get 'ComponentManager' Object
componentManager = ComponentManager.getInstance()
//Get 'CustomFieldManager' Object
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()

//Get Custom Field Object
CustomField codeReview = customFieldManager.getCustomFieldObject(10106)

//Update Custom field's value.
myIssue.setCustomFieldValue(codeReview, issueKey)

passesCondition = false

You can select custom field object with its name. But it’s better to use field id numeric value because it’s not changed after a custom field was created. With this feature, you can change field name .

Advertisements

Author: all4dich

http://webchat.freenode.net/?channels=node.js

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s