如何使用jira中的侦听器获取自定义字段的字符串值(单选项)

发布于 2025-02-08 10:54:24 字数 497 浏览 1 评论 0原文

我是JIRA的新学习者,我没有脚本跑步者的经验,我尝试在Scriptrunner中编写脚本,每当用户选择“其他”选项时,该脚本会启动。 “另一个”是我在自定义字段中添加的四个选项之一,该字段的类型是单个选择。 我所做的是Open Scriptrunner>创建听众>选择自定义听众>选择项目>并编写此脚本:

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObjectByName("impacted")
def cFieldValue = issue.getCustomFieldValue(cField)

If cFieldValue== "Other"    
  return "there is no another option"

此脚本不适合我。任何人都可以给我吗? 有人可以给我建议或帮助脚本吗?

I am a new learner of Jira and I have no experience with Script runner, And I trying to Write a script in ScriptRunner that gets initiated every time a user selects the “other” option. the "other" is one of four options which I added it under custom field and the type of this field is single select.
what i have done is open scriptrunner> create listener> choose Custom listener> select the project> and write this script:

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObjectByName("impacted")
def cFieldValue = issue.getCustomFieldValue(cField)

If cFieldValue== "Other"    
  return "there is no another option"

this script didn't work with me. can any one give me .
Can someone give me advice or help for script?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小嗲 2025-02-15 10:54:24

只需附加.toString()

def cFieldValue = issue.getCustomFieldValue(cField).toString()

maby您就可以用以下方式替换整个代码

def cFieldValue = issue.getCustomFieldValue("impacted").toString()

Simply append a .toString()

def cFieldValue = issue.getCustomFieldValue(cField).toString()

Maby you can replace your whole code with:

def cFieldValue = issue.getCustomFieldValue("impacted").toString()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文