1
0
-1

User is unable to synchronize request type fields between Zendesk and Jira Cloud by using the following below method:

issue.customFields."Request Type".value = replica.customKeys."Tier 3 Domain" 

but instead user is getting the following error message

Can't find Customer Request type `BIMcloud SaaS Related Issue` in Service Desk for project `IT Service Desk`. 
Known Request types: WiFi Issue,Report a system problem,Forward/SSA Related Issue,E-mail sending or receiving issue,Ask a question,SuccessFactors,Allowlist E-mail Sender,Nexthink (Issue, Question or Request),Community Related Issue,Peripheral Device Request,Remote Access Request,Membership request,MS Azure admin or service user request,Windows Install Request,Remote Access Issue,DATA Server Folder Access,Apttus,Service User Request,Access request,Endpoint Protection Issue,Install New Hardware,Access request,SalesForce CPQ,Hardware Issue,Emailed request,Phishing email,Navision / Business Central,DNS Record Request,Leaver,Starter,GSPOS Access Request,Event support,Picture upload for contractors,License Delivery - Apttus Related Issue,NPS Related Issue,GSPOS Related Issue,Teams Related Request,Purchase Related Issue,User Logon Issue,Mobile Device Enrollment,Distribution List Request,I couldn't find the right category for my issue,MacOS Install Request,Domain Registration,Printer / printing issue,System Access Request,Employee related data modification,Learn Portal Related Issue,BIMx Transfer Site Related Issues,Intune / Company Portal / zIPS issue 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.

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.


    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hey, Harold Oconitrillo , please try using this approach:

      1. add to the end of your script

        class PageDigestedResult {
            def result;
            boolean stop;
            PageDigestedResult(result, boolean stop) {
                this.result = result
                this.stop = stop
            }
        }
      2. 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...