1
0
-1

Hello there,


I need to get IDs of Groups to which Request from JSM belongs to. Typically from REST API I could just access the field "Request Type" which has the "groupIds" property. Below is an example how the "Request Type" field looks returned from a REST API.

{
    "customfield_10010": {
        "_links": {},
        "requestType": {
            "_expands": [
                "field"
            ],
            "id": "166",
            "_links": {},
            "name": "Other",
            "description": "",
            "helpText": "",
            "issueTypeId": "10003",
            "serviceDeskId": "1",
            "portalId": "1",
            "groupIds": [
                "30"
            ],
            "icon": {}
        },
        "currentStatus": {
            "status": "Waiting for support",
            "statusCategory": "INDETERMINATE",
            "statusDate": {
                "iso8601": "2023-10-09T11:24:33+0000",
                "jira": "2023-10-09T11:24:33.295+0000",
                "friendly": "Yesterday 11:24 AM",
                "epochMillis": 1696850673295
            }
        }
    }
}

As you can see to access groupIds I would just simply use path customfield_10010.requestType.groupIds.

How do I achieve that in the outgoing sync script? Tried:

issue.customFields."Request Type".requestType.groupIds

issue.customFields."Request Type".value.requestType.groupIds

issue.customFields."Request Type".value - this returned null/null for some reason even though the script ran on a Request


Thanks

    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      Hi Vojtěch Veselý!

      After some research, we found a way to bring the groupIds.

      def request = new JiraClient(httpClient)
           .http(
                              "GET",
                              "/rest/api/3/issue/${issue.key}",
                              [:],
                              null,
                              ["Accept": ["application/json"], "Content-type" : ["application/json"]]
          )
          {
              response ->
              if (response.code >= 400)
                  throw new com.exalate.api.exception.IssueTrackerException("Failed")
              else
                  (new groovy.json.JsonSlurper()).parseText(response.body)
          }
      def groupIds = request.fields.customfield_10010.requestType.groupIds
      replica.customKeys."Group IDS" = groupIds
      
      

      Add this to your Outgoing Script, and it should work to retrieve the groupIds as per your example and be able to send it.


      BR


      Tomas Lalanne

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

        The issue."Request Type" doesn't have the "groupIds" property either. IT has just:
        [serviceDeskProjectKey, class, requestTypeKey, serviceDeskProjectName, serviceDeskId, representationValue, requestTypeName, requestTypeId, portalKey]

          CommentAdd your comment...