Code Monkey home page Code Monkey logo

Comments (15)

bobcarroll avatar bobcarroll commented on July 20, 2024

Interesting. This might be similar to another issue someone e-mailed me about. Do you happen to know what the JSON is expected to look like? I haven't come across that field type before.

from jira-client.

andrew-boutin avatar andrew-boutin commented on July 20, 2024

Does this help you at all?

"customfield_10023":[{"value":"Yes","id":"10013"}]

I got this by viewing the issue's fields in a debugger after retrieving an issue from Jira - I manually set the checkbox using the Jira web interface so that's what it should "look like" when a checkbox is checked.

Thanks for the fast response on this!

EDIT:
I don't know if this helps, but this is the format from a text field custom field.

"customfield_10011":{"value":"Customer","id":"10001"}

from jira-client.

bobcarroll avatar bobcarroll commented on July 20, 2024

Yes that does help. I'll take a look soon.

from jira-client.

chaplinkyle avatar chaplinkyle commented on July 20, 2024

What I have found so far:

I set up the same type of custom field in jira-client.atlassian.net. When you login check out https://jira-client.atlassian.net/rest/api/2/issue/JIR-1/editmeta.

Field in question metadata: "customfield_10027":{"required":false,"schema":{"type":"array","items":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes","customId":10027}

Schema defines array of type string and that is what we're passing. I checked.

from jira-client.

andrew-boutin avatar andrew-boutin commented on July 20, 2024

@chaplinkyle Did you attempt to set one of the checkboxes in the multicheckbox using jira-client? Thanks for taking the time to look into this!

from jira-client.

andrew-boutin avatar andrew-boutin commented on July 20, 2024

I'm not sure if the meta data I retrieved for my custom field helps in this issue or not:

customfield_10025 {"required":false,"schema": "type":"array","items":"string","custom":"com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes","customId":10025},"name":"Customer Data Loss Flag","hasDefaultValue":false,"operations":["add","set","remove"],"allowedValues":[{"self":" ...server url... /jira/rest/api/2/customFieldOption/10014","value":"Yes","id":"10014"}]}

from jira-client.

andrew-boutin avatar andrew-boutin commented on July 20, 2024

I have managed to set checkboxes, here is how:

Issue symptom = jiraClient.getIssue("EM-559");

JSONObject valueObject = new JSONObject(); // from import net.sf.json.JSONObject;
valueObject.put("value", "Yes"); // Yes it the only option for this particular checkbox field
ArrayList<Object> fields = new ArrayList<Object>();
fields.add(valueObject);

symptom.update().field("customfield_10023", fields).execute();

I'm not sure if it was designed to only work this way or if there is another way. If not then I hope what I have found helps you fix the implementation. At the least maybe now some comments can be made about how to set checkboxes with jira-client. Thanks again for the awesome tool.

from jira-client.

bobcarroll avatar bobcarroll commented on July 20, 2024

That helped a lot actually. The problem is the metadata returned by JIRA lies about what the type actually is. An array of strings (as the metadata indicates) should be an array of strings, but it's really expecting an array of dictionaries.

Can you build jira-client from master and try this:

Issue symptom = jiraClient.getIssue("EM-559");
symptom.update().field("customfield_10023", new ArrayList<Object>() {{ add("Yes") }}).execute();

from jira-client.

stevegore avatar stevegore commented on July 20, 2024

Hi
I'm having this issue for all multi-select fields. I've tried your suggestion above to no avail. Any other suggestions? I've noticed there's an open feature request for this as well. #93

from jira-client.

andrew-boutin avatar andrew-boutin commented on July 20, 2024

I just confirmed that this worked for me. I created a custom field of type "Select List (multiple choices)" called "multiSelectTest" with custom field id "10101". The available options were "one", "two", and "three".

Issue problem = jiraClient.getIssue("EM-8648");

JSONObject oneObject = new JSONObject(); // from import net.sf.json.JSONObject;
oneObject.put("value", "one");
JSONObject twoObject = new JSONObject();
twoObject.put("value", "two");

ArrayList<Object> fields = new ArrayList<Object>();
fields.add(oneObject);
fields.add(twoObject);

problem.update().field("customfield_10101", fields).execute();

The String representation of 'fields' is "[{"value":"one"}, {"value":"two"}]".

Hope this helps!

from jira-client.

stevegore avatar stevegore commented on July 20, 2024

Thanks for this. I actually resolved the issue by making a change to the client. I'll try and create a pull request tomorrow.

from jira-client.

andrew-boutin avatar andrew-boutin commented on July 20, 2024

I'm interested in knowing what wasn't working correctly with the client, I thought it was working correctly.

from jira-client.

stevegore avatar stevegore commented on July 20, 2024

Thanks for this. I actually resolved the issue by making a change to the client. I'll try and create a pull request tomorrow.
On 24 Jul 2015 12:29 am, Andrew Boutin [email protected] wrote:I just confirmed that this worked for me. I created a custom field of type "Select List (multiple choices)" called "multiSelectTest" with custom field id "10101". The available options were "one", "two", and "three".

Issue problem = jiraClient.getIssue("EM-8648");

JSONObject oneObject = new JSONObject(); // from import net.sf.json.JSONObject;
oneObject.put("value", "one");
JSONObject twoObject = new JSONObject();
twoObject.put("value", "two");

ArrayList fields = new ArrayList();
fields.add(oneObject);
fields.add(twoObject);

problem.update().field("customfield_10101", fields).execute();

The String representation of 'fields' is "[{"value":"one"}, {"value":"two"}]".

Hope this helps!

β€”Reply to this email directly or view it on GitHub.

from jira-client.

stevenlordiam avatar stevenlordiam commented on July 20, 2024

Can you update this merged code in Maven repo? Need this API so much. Thanks. @rcarz

BTW the define JSON method is not working for me. I used code from Maven 0.5 version. Returns:
Field 'customfield_10101' does not exist or read-only.

from jira-client.

vzenzo avatar vzenzo commented on July 20, 2024

Can somebody help with this? None of the options up there work for me, I constantly get

400 400: {"errorMessages":[],"errors":{"Detected on Env":"expected Object","Country":"expected Object"}}

I've added them as objects

    JSONObject envObject = new JSONObject();
    envObject.put("value", "UAT");
    envObject.put("id","10911");

    JSONObject countryObject = new JSONObject();
    countryObject.put("value", "RO");
    countryObject.put("id", "10900");

newIssue.field("customfield_11500", new ArrayList() {{add(countryObject);}})
.field("customfield_11503", new ArrayList() {{add(envObject);}})
.execute();

from jira-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.