使用Jira中的REST api修改自定义字段名称后,CustomFieldManager没有获得自定义字段 [英] CustomFieldManager is not getting the custom field after modifying the custom field name using REST api in jira

查看:640
本文介绍了使用Jira中的REST api修改自定义字段名称后,CustomFieldManager没有获得自定义字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JIRA中的REST API更改自定义字段名称。
它正在成功更改自定义字段名称。
但是,当我尝试将自定义文件提交到代码中时,结果为null。

I'm changing the custom field name using the REST api in JIRA. It is changing the custom field name suceessfully. But when I tried to get the custom filed in the code, I'm getting null as the result.

String modByWhomCustomFieldName = pluginConfigService.getMUFCustomFieldName();
    System.out.println("+++++++++++++++++++In flagCustomField() modByWhomCustomFieldName is:"+modByWhomCustomFieldName);

    //CustomField modByWhomCustomField = cfManager.getCustomFieldObjectByName("Description Changed By");
    CustomField modByWhomCustomField = cfManager.getCustomFieldObjectByName(modByWhomCustomFieldName);
    if(modByWhomCustomField != null) {
        System.out.println("++++++++++++++ "+modByWhomCustomField.getDescription());
    }

在上面,它没有进入if条件。

In the above it is not entering into the if conditon.

从这里编辑。
每当用户更改问题描述时,我都会显示该用户。为此,我创建了一个类型为 UserCFType的自定义字段。它显示的是修改说明的用户。但是对于用户admin,它将显示admin(admin)。我只希望 admin而不是 admin(admin)。

Edited from here. Whenever user changed the description of an issue, I'm displaying that user. For this I have created one custom field of type "UserCFType" . It is displaying the user who modified the description. But for user admin, it is displaying admin(admin) . I just want "admin" only not "admin(admin)".

Object modByWhomCustomFieldOldValue = issue.getCustomFieldValue(modByWhomCustomField);
        Object modByWhomCustomFieldNewValue = user;
        System.out.println("+++++++++++++++++++In flagCustomField() current user is:"+modByWhomCustomFieldNewValue.toString());

        ModifiedValue<Object> modifVal2 = new ModifiedValue<>(modByWhomCustomFieldOldValue, modByWhomCustomFieldNewValue);
        modByWhomCustomField.updateValue(null, issue, modifVal2, changeHolder);

上面是该代码。

推荐答案

尝试,获取值。当您获得customfield对象时,您将获得CF本身,而不是任何情况下该自定义字段的值。因此,您将获得自定义字段,然后获得针对特定问题的值:

try, getting the value. When you get the customfield object, you are getting the CF itself, not the value of that custom field at any issue. So, you get the custom field, and then the value of it for a specific issue:

cfManager.getCustomFieldObjectByName(modByWhomCustomFieldName).getValue(yourIssue)

**编辑:
对于显示名称的问题,请尝试使用用户对象上的 getDisplayName()方法。
的问候

** For the name displaying problem, try using the getDisplayName() method on user object. Regards

这篇关于使用Jira中的REST api修改自定义字段名称后,CustomFieldManager没有获得自定义字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆