官术网_书友最值得收藏!

How to do it...

Creating a scripted field is a two-step process. We first need to create an instance of the custom field in Jira, and then add the script to it:

  1. Log into Jira with a user that has a Jira administrator's permission.
  2. Navigate to Administration > Issues > Custom fields.
  3. Click on the Add Custom Field button and select Advanced from the dialog box.
  1. Scroll down and select Scripted Field from the list; click on Next, as shown in the following screenshot:
  1. Name our new custom field Total Comments and add it to the appropriate screens.
  2. Navigate to Administration > Manage apps > Script Fields.
  3. Select the Edit option for the Total Comments field.
  4. Enter the following Groovy script in the script text box:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.CommentManager

def commentManager = ComponentAccessor.getCommentManager()
def numberOfComments = commentManager.getComments(issue).size()

return numberOfComments ? numberOfComments as Double : null
  1. Select Number Field for Template and click on Update, as shown in the following screenshot:

When the custom field is added to an issue, it will automatically calculate the number of comments the issue has in real time, as shown in the following screenshot:

Now it's time to look to understand the steps.

主站蜘蛛池模板: 鄂尔多斯市| 潮安县| 安阳市| 荥阳市| 巴楚县| 桓台县| 青龙| 缙云县| 仁寿县| 自治县| 扎鲁特旗| 微博| 连城县| 桓台县| 新竹市| 漾濞| 炉霍县| 乌审旗| 丹阳市| 通州区| 南宁市| 砀山县| 收藏| 皋兰县| 普格县| 阜阳市| 澜沧| 光山县| 浑源县| 抚远县| 镇雄县| 微山县| 临夏市| 岳阳县| 涿鹿县| 卫辉市| 英吉沙县| 山东省| 黄大仙区| 黑河市| 郯城县|