Questions for Confluence license has expired.

Please purchase a new license to continue using Questions for Confluence.

Loop checkbox values or multiple select to create multiple projects

 
1
0
-1

Is there any way I can loop the value I get from the checkbox/multiple select and use it to determine which project in JIRA for a new issue to be created?



For example something along the way as below:


def checkboxCollection = replica.customFields."Create in the customer facing projects"?.
                                value?.
                                collect{
                                        a->
                                        nodeHelper.getOption (issue, "Create in the customer facing projects", a.value)
                                        }
For each (checkboxCollection) {
        issue.projectKey = nodeHelper.getProject(replica.project?.key)?.key ?: checkboxCollection
        issue.typeName   = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Service Request"
}
    CommentAdd your comment...

    5 answers

    1.  
      1
      0
      -1

      Hi Iona Augustine ,


      I am sorry if I get you confused with my answer.


      We would like to understand closely your requirements about this configuration.

      For example:

      There are two instances "A" and "B".


      "A" side has a multi-box selection custom field and there are values like: ("V1", "V2", "V3") and they could be selected either in one or a few options, or even 0.


      So, we would like to figure out how the B side should understand which project to choose by selected values on the A side? Could you please elaborate about it?


      Thank you,

      Andrii

      1. Iona Augustine

        Hi Andrii, 


        In pseudo code, I probably put it as below


        def remoteCheckboxes = replica."Remote Checkbox".collect {it.value}

        For each remoteCheckbox in remoteCheckboxes

        {
            issue.projectKey = remoteCheckbox[X]
        }​


        So if the value of remoteCheckboxes from "Remote Checkbox" is ("V1", "V2", "V3"), then 3 issues would be created in 3 different projects which are in V1, V2 and V3


        I hope this helps.

        Thanks!

      2. Andrii Markov

        Hi Iona Augustine ,


        Thank you for the update!

        I am working on the workaround for you


        Kind Regards,
        Andrii

      CommentAdd your comment...
    2.  
      1
      0
      -1

      Hi Iona Augustine ,


      I am sorry for such a huge delay.


      As a workaround I would like to suggest to make an array of your checkbox.
      For example:

      issue."Multi checkbox" = ["option 1", "option 2"]
      issue."Multi checkbox" = replica."Remote Checkbox".collect {it.value}


      Also, more information you could find over here:

      https://docs.idalko.com/exalate/display/ED/How+to+synchronize+list+custom+fields


      Kind Regards,
      Andrii

      1. Iona Augustine

        Hi Andrii,


        How do I make of this? I am not looking to sync the field. I am looking to use the values in the field so I can loop it to determine which project in JIRA to sync my issue to.


        I am more than happy to explain more if need better explanation.

      2. Iona Augustine

        I actually found this


        def projectMapping = ["SERVA":"CLOUDA", "SERVB":"CLOUDB"] // ["REMOTE PROJECT KEY": "LOCAL PROJECT KEY"]
        issue.projectKey = projectMapping[replica.project.key]


        from this page:

        https://docs.idalko.com/exalate/pages/viewpage.action?pageId=19629012


        I modified it and used it as below:


        def projectMapping = replica."Create in the customer facing projects".collect {it.value}
        
        issue.projectKey = projectMapping[replica.project.key]
        issue.typeName   = "Service Request"


        The run the connection, I got the below error:


        HTTP Status 400 – Bad Request
        
        services.jcloud.exception.JiraCloudTrackerException: Could not find project `[]` in this Jira Cloud:
      CommentAdd your comment...
    3.  
      1
      0
      -1

      Hi Andrii, to top up my previous comment, the reson we use checbox is to be able to select multiply. The script you gave me is good is the selection is single.


      We want to be able to select more than one selection and be able to loop it and create project based on it,


      I hope this helps. Thanks!

      1. Serhiy Onyshchenko

        Hello, Iona Augustine 
        As far as I understand your use case, you have a checkbox custom field on source side (let's call it Source for now), the checkbox lists different project keys from Destination side.
        A user on Source side is supposed to tick one or multiple boxes in this custom field, and you'd like that Exalate creates an issue on Destination side in each project, right?
        Regards, Serhiy.

      2. Iona Augustine

        Hi Serhiy,


        Yes! exactly that. So the script will be dynamic with less or no maintenance at all.


        Thanks!

        Iona

      CommentAdd your comment...
    4.  
      1
      0
      -1

      Thanks for that Andrii, 


      This should work, but I am looking something more dynamic, without specifying the value at all.


      So if today I have 2 values within the checkbox i.e. Project A, project B, project C. Then tomorrow I added project D, I dont have to modify the script each time.


      Does this make sense?

        CommentAdd your comment...
      1.  
        1
        0
        -1

        Hi Iona Augustine ,


        You can try to create a condition with a revising if your checkbox has been checked or not.

        Please notice that if you are sure that in your customfields all the checkboxes have some value, you should use a non-commented condition. If not, you should use the commented one.


        Also, please let us know if it worked for you.


        if (replica."Create in the customer facing projects".any {box->box.value == "example"})
        //if (replica."Create in the customer facing projects"?.any {box->box.value == "example"})
                {
        issue.projectKey = "example"
        }​



        1. Iona Augustine

          Hi Andrii, anything on this yet? If it's not possible then it's OK, we'll work a workaround.

        CommentAdd your comment...