【问题标题】:Setting a default description based on a custom field selection in Jira根据 Jira 中的自定义字段选择设置默认描述
【发布时间】:2015-03-24 06:37:10
【问题描述】:

我是使用 Velocity 的新手,但这是我正在尝试做的。

基于问题类型“服务请求”和自定义字段选项“a”设置描述以显示“x”

基于问题类型“服务请求”和自定义字段选项“b”设置描述以显示“y”

基于问题类型“服务请求”和自定义字段选项“c”设置描述以显示“z”

我为此使用了以下内容

if (($issue.key == '') & ($issue.type().getname == 'service request') & ($customfieldmanager().getcustomfieldoption = '11504') & ($id == 'a'))
set ($description = 'x')

elseif ($id == 'b')
set ($description = 'y')

else ($id == 'c')
set ($description = 'z')

似乎无法识别自定义字段 ID 或自定义字段选择 ID。

任何人都建议这里可能出了什么问题,我没有运气,尝试了几种不同的方法,并花了几天时间试图解决这个问题。

我们将不胜感激。

【问题讨论】:

    标签: jira


    【解决方案1】:

    对于逻辑“AND”,使用“&&”而不是“&”。请看这里:http://velocity.apache.org/engine/devel/user-guide.html#relationalandlogicaloperators

    if, else, set 前面应该有“#”。

    如果还需要“结束”:https://click.apache.org/docs/velocity/user-guide.html#conditionals

    在您的示例中,问题和 customfieldmanager 应该在速度范围内。因此 JIRA(或您的 JIRA 插件)操作应该具有适当的 getIssue() 和 getCustomFieldManager() 方法,并且您可以以 $issue 和 $customFieldManager(或 $getIssue() 和 $getCustomFieldManager())的形式快速访问它们。注意大小写和括号。 getname 和 getcustomfieldoption 的情况类似。请看这里:https://stackoverflow.com/a/17069545/1537800

    我不确定方法名称中的小写/大写,但更正后的版本可能如下所示:

    #if ($issue.key == '' && $issue.getType().getName() == 'service request' && $customFieldManager.getCustomFieldOption() == '11504' && $id == 'a')
    #set ($description = 'x')
    
    #elseif ($id == 'b')
    #set ($description = 'y')
    
    #else ($id == 'c')
    #set ($description = 'z')
    #end
    

    【讨论】:

    • 您好,谢谢,但这也没有用。如何在使用 MySQL 的数据库中调用 customfieldoption ID,我将使用: select ID from customfieldoption where customfield = '11504';从该自定义字段中调用 3 个选项。我将如何在速度模板中使用它,以便描述根据 customfieldi iD 选择而改变
    • 不确定这是否已经完成,但还有其他方法可以得到我想要的吗?
    猜你喜欢
    • 2016-05-09
    • 1970-01-01
    • 2020-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多