1
0
-1
1 answer
- 10-1
Hey, Harold Oconitrillo , please try using this approach:
add to the end of your script
class PageDigestedResult { def result; boolean stop; PageDigestedResult(result, boolean stop) { this.result = result this.stop = stop } }
replace
issue.customFields."Request Type".value = replica.customKeys."Tier 3 Domain"
with
def requestTypeName = replica.customKeys."Tier 3 Domain" def paginate paginate = { offset, limit, result, getPageFn, Closure<PageDigestedResult> consumePageFn -> def page = getPageFn(offset, limit) if (page.empty) { return result } else { pageDigestedResult = consumePageFn(page, result) result = pageDigestedResult.result if (pageDigestedResult.stop) return result else paginate(offset + limit, limit, result, getPageFn, consumePageFn) } } def js = new groovy.json.JsonSlurper() def parseResult = { request -> { response -> if(response.code >= 300) debug.error( "Failed to ${request.method} ${request.path}" + "${(request.queryParams && !request.queryParams.empty) ? "?${request.queryParams.collect{ k,v -> "$k=$v"}.join("&")}" : ""}" + "${request.body ? " with body ${request.body}" : ""}" + " response: ${response.code} ${response.body}" ) else js.parseText(response.body) }} if (requestTypeName) { def jc = new JiraClient(httpClient) def findSdId = { projectKey -> paginate( 0, 50, ["result":null], { int o, int l -> def request = [ "method": "GET", "path": "/rest/servicedeskapi/servicedesk", "queryParams": ["start":[o.toString()],"limit":[l.toString()]], "body": null, "headers": ["Content-Type":["application/json"]] ] def searchResult = jc.http( request.method, request.path, request.queryParams, request.body, request.headers, parseResult(request) ) searchResult.values }, { page, result -> /* [ { "id": "10001", "projectId": "11001", "projectName": "IT Help Desk", "projectKey": "ITH", "_links": { "self": "https://your-domain.atlassian.net/rest/servicedeskapi/servicedesk/10001" } } ] */ def sd = page.find { it.projectKey == projectKey } new PageDigestedResult([sd.id], sd != null) } )?.find() } def pk = issue.projectKey ?: issue.project?.key def sdId = findSdId(pk) if (!sdId) { debug.error("Service desk ID not found for project $pk") } def requestTypeJson = paginate( 0, 50, [:], { int o, int l -> def request = [ "method": "GET", "path": "/rest/servicedeskapi/servicedesk/${sdId}/requesttype", "queryParams": ["start":[o.toString()],"limit":[l.toString()]], "body": null, "headers": ["Content-Type":["application/json"]] ] def searchResult = jc.http( request.method, request.path, request.queryParams, request.body, request.headers, parseResult(request) ) searchResult.values }, { page, result -> /* [ { "_expands": [], "id": "11001", "name": "Get IT Help", "description": "Get IT Help", "helpText": "Please tell us clearly the problem you have within 100 words.", "issueTypeId": "12345", "serviceDeskId": "28", "portalId": "2", "groupIds": [ "12" ] } ] */ def rt = page.find { it.name.equalsIgnoreCase(requestTypeName) } new PageDigestedResult([rt], rt != null) } )?.find() if (requestTypeJson) { def requestType = new com.exalate.basic.domain.hubobject.v1.BasicHubVpOrigin() /* private String portalKey; private String requestTypeKey; private String representationValue; private String requestTypeId; private String requestTypeName; private String serviceDeskId; private String serviceDeskProjectName; private String serviceDeskProjectKey; */ requestType.requestTypeId = requestTypeJson.id requestType.requestTypeName = requestTypeJson.name issue.customFields."Request Type".value = requestType } }
Let me know, how it goes.
Regards, Serhiy.CommentAdd your comment...
Overview
Content Tools
search
attachments
weblink
advanced
User is unable to synchronize request type fields between Zendesk and Jira Cloud by using the following below method:
but instead user is getting the following error message
Possible reason
As I counted the request types in the Exalate error message list it contains only 50 request types (In the IT Service Desk we have more than 50 request types) which is the default response amount from Jira cloud.
Kind regards.