2017-01-17 19 views
-1

Ответы на этот вопрос устарели или неполны во всех источниках, которые я проверил.Как обновить настраиваемое поле в jira 7+ с помощью java

Вот некоторые примеры:

Delete issue in JIRA using Java

How do I save a value into a custom field in JIRA programmatically?

JIRA creating issue using java

Automating custom field value change in JIRA

Jira: How to obtain the previous value for a custom field in a custom IssueEventListener

CustomFieldManager is not getting the custom field after modifying the custom field name using REST api in jira

У меня недостаточно отзывов, чтобы комментировать любые ваши вопросы. Но у меня есть ответ.

+1

Является ли это вопрос или ответ? –

+2

Я голосую, чтобы закрыть этот вопрос как не по теме, потому что это не вопрос. – khelwood

+0

Ответ на 6 вопросов. Все ответы на них устарели в 2017 году и не помогли мне. У меня нет 10 репутации, поэтому я решил написать свой ответ в качестве вопроса. Что еще я должен делать, если не могу просто оставить комментарий где-нибудь? –

ответ

1

Так вот мое решение:

CustomField csUserField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(fieldName); 
IssueService issueService = ComponentAccessor.getIssueService(); 
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters(); 
issueInputParameters.addCustomFieldValue(csUserField.getId(), value_string); 
issueInputParameters.setSkipScreenCheck(true); 
issueInputParameters.setRetainExistingValuesWhenParameterNotProvided(true, true); 
UpdateValidationResult updateValidationResult = issueService.validateUpdate(user, issue.getId(), issueInputParameters); 
if (updateValidationResult.isValid()) 
{ 
    IssueResult updateResult = issueService.update(user, updateValidationResult); 
    if (!updateResult.isValid()) 
    { 
     log.warn("ISSUE has NOT been updated. Errors: {}\n", updateResult.getErrorCollection().toString()); 
    } 
    else 
    { 
     log.warn("ISSUE has been updated.\n"); 
    } 
} 
else 
{ 
    log.warn("ISSUE has NOT been updated. Errors: {}\n", updateResult.getErrorCollection().toString()); 
}