Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,553,397
Community Members
 
Community Events
184
Community Groups

How to set the value of a custom field via JRJC?

Edited

I'm trying to use JRJC to create an issue, and I must set a custom field before that is successful. I tried searching for examples, but did not find any.

Here's the code I am using to create the issue:

    Long testIssueTypeId = getTestIssueTypeId(projectKey);

    IssueInputBuilder builder = new IssueInputBuilder()
        .setProjectKey(projectKey)
        .setIssueTypeId(testIssueTypeId)
        .setSummary(summary)
        .setDescription(description);

    IssueInput input = builder.build();

    return jira.getIssueClient().createIssue(input).claim();

 To the list of attributes, I need to set a custom field called "Application". In the JSON of a similar issue it appears like this:

{
  "self": "https://jira.web.labs.att.com/rest/api/2/customFieldOption/14314",
  "value":"NA:12345",
  "id": "14314",
  "disabled": false
}

What code do I need to add to the IssueInputBuilder to set this field's value? Or is there another, more preferred approach?

Thanks!

 

EDIT:

Here's what I've tried (for another custom field):

    IssueInputBuilder builder = new IssueInputBuilder()
        .setProjectKey(projectKey)
        .setIssueTypeId(testIssueTypeId)
        .setSummary(summary)
        .setDescription(description)
        .setFieldValue("Test Type",
new CustomFieldOption(14314L, null, "Functional", null, null));

 

With this code, I get the following error:

RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={Test Type=Field 'Test Type' cannot be set. It is not on the appropriate screen, or unknown.}, errorMessages=[]}]}

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events