如何使用jira-plugin在JIRA中创建问题时填充字段的默认值?

问题描述 投票:0回答:1

我正在研究jira-plugin以在JIRA中创建问题。我正在使用方法 - create(user,createValidationResult)来创建问题。

我需要在创建时给出必填字段的值。

我想在创建时给出字段的默认值。 (默认值是在JIRA中创建这些值时配置的值)

我找到了以下方法

  1. 方法populateDefaults
  2. 方法getDefaultValue

但是这两种方法都需要Issue-参数,这个参数尚未创建,因为我需要在设置默认值后创建问题

请告诉我如何设置这些字段的值。使用类addCustomFieldValue中的方法IssueInputParameters添加这些字段

java jira jira-rest-api jira-plugin atlassian-plugin-sdk
1个回答
1
投票

我自己找到了解决方案:(这很完美)

使用以下方法:

    IssueInputParameters issueInputParameters = 
                                    issueService.newIssueInputParameters();

    issueInputParameters.setApplyDefaultValuesWhenParameterNotProvided(true);

    IssueService.CreateValidationResult createValidationResult = 
                         issueService.validateCreate(user, issueInputParameters);

    issueService.create(user,createValidationResult);

注意:在上面的代码中,'issueService'是IssueService的一个对象。

© www.soinside.com 2019 - 2024. All rights reserved.