Uploaded image for project: 'OpenICF'
  1. OpenICF
  2. OPENICF-966

ServiceNow: Sorting doesn't work at queries request

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: servicenow-connector-1.5.0.0
    • Component/s: ServiceNow Connector
    • Labels:
    • Environment:
      ServiceNowConnector: 1.5.1.0-SNAPSHOT afe43cba2e7,
      OpenIDM version "6.5.0-SNAPSHOT" 6f21de8,
      Linux Mint 18.2 64-bit,
      openjdk version "1.8.0_181"

      Description

      `_sortKeys` doesn't have effect at queries requests for serviceNow connector. However we are able to sorting at REST API for servicenow developer instance (for example use REST API exploler tools at serviceNow developer instance web page).

      Steps to reproduce:

      1. Download, unzip openidm, start openidm and set up serviceNow connector according documentation
      2. When exists less than 2 records in user table so create more records e.g.
        curl --header "X-OpenIDM-Username: openidm-admin" --header "X-OpenIDM-Password: openidm-admin" --header "Content-Type: application/json" --data '{"first_name": "FR_0", "last_name": "LN_10", "email": "UserTest_0_0@example.com", "phone": "555-123-1230", "user_name": "C_0_153854813958"}' --request POST "http://localhost:8080/openidm/system/serviceNow/user?_action=create"
        
        curl --header "X-OpenIDM-Username: openidm-admin" --header "X-OpenIDM-Password: openidm-admin" --header "Content-Type: application/json" --data '{"first_name": "FR_1", "last_name": "LN_9", "email": "UserTest_1_1@example.com", "phone": "555-123-1231", "user_name": "C_1_153854814204"}' --request POST "http://localhost:8080/openidm/system/serviceNow/user?_action=create" 
      3. SEND GET request with queryFilter=True and without setup `_sortKeys` parametr
        curl --header "X-OpenIDM-Username: openidm-admin" --header "X-OpenIDM-Password: openidm-admin" --request GET "http://localhost:8080/openidm/system/serviceNow/user?_queryFilter=True&_fields=last_name | jq
        
         {
          "result": [
            {
              "_id": "06f97342c37030009b5efcfc5bba8fc3",
              "last_name": "User"
            },
            {
              "_id": "5136503cc611227c0183e96598c4f706",
              "last_name": "Guest"
            },
            {
              "_id": "6816f79cc0a8016401c5a33be04be441",
              "last_name": "Administrator"
            },
            {
              "_id": "7772a97e0fd71300760b06ace1050eb1",
              "last_name": "153855377050"
            },
            {
              "_id": "ccde656f0f706300760b06ace1050e3a",
              "last_name": "LN_6"
            },
            {
              "_id": "dd9b3742c37030009b5efcfc5bba8fb6",
              "last_name": "Admin"
            },
            {
              "_id": "f2dead6f0fb06300760b06ace1050ed6",
              "last_name": "LN_1"
            },
            {
              "_id": "f5dead6f0fb06300760b06ace1050ed1",
              "last_name": "LN_3"
            }
          ],
          "resultCount": 8,
          "pagedResultsCookie": null,
          "totalPagedResultsPolicy": "NONE",
          "totalPagedResults": -1,
          "remainingPagedResults": -1
        }
      4. SEND GET request with queryFilter=True and with `_sortKeys=last_name`
        curl --header "X-OpenIDM-Username: openidm-admin" --header "X-OpenIDM-Password: openidm-admin" --request GET "http://localhost:8080/openidm/system/serviceNow/user?_queryFilter=True&_fields=last_name&_sortKeys=last_name" | jq
        
        {
          "result": [
            {
              "_id": "06f97342c37030009b5efcfc5bba8fc3",
              "last_name": "User"
            },
            {
              "_id": "5136503cc611227c0183e96598c4f706",
              "last_name": "Guest"
            },
            {
              "_id": "6816f79cc0a8016401c5a33be04be441",
              "last_name": "Administrator"
            },
            {
              "_id": "7772a97e0fd71300760b06ace1050eb1",
              "last_name": "153855377050"
            },
            {
              "_id": "ccde656f0f706300760b06ace1050e3a",
              "last_name": "LN_6"
            },
            {
              "_id": "dd9b3742c37030009b5efcfc5bba8fb6",
              "last_name": "Admin"
            },
            {
              "_id": "f2dead6f0fb06300760b06ace1050ed6",
              "last_name": "LN_1"
            },
            {
              "_id": "f5dead6f0fb06300760b06ace1050ed1",
              "last_name": "LN_3"
            }
          ],
          "resultCount": 8,
          "pagedResultsCookie": null,
          "totalPagedResultsPolicy": "NONE",
          "totalPagedResults": -1,
          "remainingPagedResults": -1
        }
        

      Actual result: Records in the response was not order by `last_name` field.

      Expected result: Records in the response should be ordered by `last_name` field.

      Note: When I tried ORDERBY and ORDERBYDESC in REST API exploler in REST API exploler in serviceNow instance, so there ordering was working correctly.

      tableName = User (sys_user)
      sysparm_query = True^ORDERBYlast_name
      sysparm_fields = last_name,email,sys_id
      sysparm_limit = 10
      
      Response:
      {
        "result": [
          {
            "sys_id": "7772a97e0fd71300760b06ace1050eb1",
            "last_name": "153855377050",
            "email": "HibernationUser@example.com"
          },
          {
            "sys_id": "dd9b3742c37030009b5efcfc5bba8fb6",
            "last_name": "Admin",
            "email": "certification.admin@example.com"
          },
          {
            "sys_id": "6816f79cc0a8016401c5a33be04be441",
            "last_name": "Administrator",
            "email": "admin@example.com"
          },
          {
            "sys_id": "5136503cc611227c0183e96598c4f706",
            "last_name": "Guest",
            "email": "guest@example.com"
          },
          {
            "sys_id": "f2dead6f0fb06300760b06ace1050ed6",
            "last_name": "LN_1",
            "email": "UserTest_1_9@example.com"
          },
          {
            "sys_id": "f5dead6f0fb06300760b06ace1050ed1",
            "last_name": "LN_3",
            "email": "UserTest_1_7@example.com"
          },
          {
            "sys_id": "ccde656f0f706300760b06ace1050e3a",
            "last_name": "LN_6",
            "email": "UserTest_0_4@example.com"
          },
          {
            "sys_id": "06f97342c37030009b5efcfc5bba8fc3",
            "last_name": "User",
            "email": "certification@example.com"
          }
        ]
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                petr.jurica Petr Jurica [X] (Inactive)
                Reporter:
                miroslav.meca Miroslav Meca
                QA Assignee:
                Miroslav Meca
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: