jira-client icon indicating copy to clipboard operation
jira-client copied to clipboard

create issue with cascading select type

Open zviederi opened this issue 8 years ago • 4 comments

Hi! I have a custom field with type customfieldtypes:cascadingselect. How to fill this cascading custom field correctly to create new issue? There is my example, which does not work.

Customfield value in JSON: "customfield_10001": {"value": "green", "child": {"value":"blue"} }

//customfield_10001 - customfieldtypes:cascadingselect. ... Map<String,Object> child = new HashMap<String,Object>(); child.put("value","blue"); Map<String,Object> parent = new HashMap<String,Object>(); parent.put("value","green"); parent.put("child",child); List<Object> cascadingArray = new ArrayList<Object>(); cascadingArray.add(parent);

Issue newIssue = jira.createIssue("TEST", "Bug") .field(Field.SUMMARY, "Bat signal is broken") .field(Field.DESCRIPTION, "Commissioner Gordon reports the Bat signal is broken.") .field(Field.REPORTER, "batman") .field("customfield_10001", parent) .execute(); ... Jira version JIRA v7.0.0-4

zviederi avatar Feb 11 '16 08:02 zviederi

@EriksZviedrans The current implementation will not support cascading select fields. I have had to hack into the codebase, to get past this problem. Hopefully once my pull request gets merged, it should be easy for you, to do it.

krmahadevan avatar Feb 12 '16 03:02 krmahadevan

I'm trying to use the latest version of the JiraClient to create an issue that contains a Cascading Select option. I am using a variation of the example given above:

      Map child = new HashMap();
    child.put("value","Architecture & Support");
    Map parent = new HashMap();
    parent.put("value","Corporate IT");
    parent.put("child",child);

    List cascadingArray = new ArrayList();
    cascadingArray.add(parent);


    List<String> pir = new ArrayList<String>();
    pir.add("PIR1234"); 

    Set<String> components = new HashSet<String>();
    components.add("Jira"); 
    components.add("WebSphere");

    /* Create a new issue. */
    Issue newIssue = jira.createIssue("AAS", IssueTypeEnum.Request.toString())
        .field(Field.SUMMARY, "Bat signal is broken")
        .field(Field.DESCRIPTION, "Commissioner Gordon reports the Bat signal is broken.")

// .field("customfield_10302", pir) .field("customfield_23001", cascadingArray) .field(Field.COMPONENTS,components) .execute(); System.out.println(newIssue);

I get the error below:

Exception in thread "main" java.lang.UnsupportedOperationException: option-with-child is not a supported field type at net.rcarz.jiraclient.Field.toJson(Field.java:669) at net.rcarz.jiraclient.Issue$FluentCreate.executeCreate(Issue.java:102) at net.rcarz.jiraclient.Issue$FluentCreate.execute(Issue.java:57) at com.example.mas.misc.CreateNewIssue.createCascadingSelect(CreateNewIssue.java:111) at com.example.mas.misc.CreateNewIssue.main(CreateNewIssue.java:22)

I have stepped through the error in a debugger, and it fails in the Field.toJson() method. The editmeta option has the parent-child values, but it seems like the Field.toJson() does not know how to handle the the 'option-with-child' type.

Am I doing something wrong, or do I need to update the Field.toJson() method to handle the 'option-with-child' type?

Thanks, Sean

SeanCharlesConlon avatar May 02 '16 17:05 SeanCharlesConlon

@SeanCharlesConlon Yes you are right. The code would fail in the toJson() method. My pull request aims at addressing it. So if you are really looking for my fix, you can try doing the following [ if my PR gets delayed in merging ]

  1. Create a duplicate package named net.rcarz.jiraclient in your own test project.
  2. Copy paste the source code [Field.java and Issue.java ] java classes in the package created in (1)
  3. Now apply the changes that are part of my pull request (#130) to the java files that are available in your project.
  4. You should now be able to use the changes as detailed in my unit test.

krmahadevan avatar May 04 '16 03:05 krmahadevan

image

in this way,successfully created.

rongyingjie avatar Nov 14 '16 09:11 rongyingjie