-1

Answers to this question are outdated or incomplete on all the sources that I checked.

Here are some examples:

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

I don't have enough reputation to comment on any of theese questions. But I have an answer.

5
  • 1
    Is this a question or an answer? Commented Jan 17, 2017 at 10:19
  • 2
    I'm voting to close this question as off-topic because it is not a question. Commented Jan 17, 2017 at 10:22
  • It's answer to 6 questions. All answers to them are outdated in 2017 and didn't help me. I don't have 10 reputation so i decided to write my answer as a question. What else should I do if can't just leave a comment anywhere? Commented Jan 17, 2017 at 11:31
  • 1
    So best thing to do is ask a question and answer it yourself. in the question mention the earlier questions are outdated and the answers not working anymore. Commented Jan 17, 2017 at 11:36
  • 1
    I feel like schizophrenic Commented Mar 3, 2017 at 11:26

1 Answer 1

1

So here is my resolution:

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());
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.