CA Service Management

 View Only
  • 1.  Use "do select" method to return the last record of the query

    Posted Aug 05, 2016 10:44 AM

    Its possible to use "Do Select" method to return the last record of the query?

     

    I need to retrieve the last value of the query, any exist a way to make it using only this webservice method?



  • 2.  Re: Use "do select" method to return the last record of the query
    Best Answer

    Posted Aug 05, 2016 01:34 PM

    From where are you using this method?

     

    Can you adjust the whereclause to get only the one you need?

     

    If not, usually webService method are called within a script/program or something similar. The method returns a list of string, you can convert it to an array, and access the last index.

    Ex : array[array.length-1] depending on the language beeing used.

     

    If your language support XML parsing or XML Node naviguating, you can read it directly with a similar approach.



  • 3.  Re: Use "do select" method to return the last record of the query

    Posted Aug 08, 2016 08:56 AM

    I have been unable to pass an ORDER BY statement to the Where Clause which would allow you to sort it by a certain field, such as last modified, starting from most recent and then only return 1 row with the doSelect call. Without the ability to do that, where you can dictate the order of the results and choose to return only the first object returned, I do not believe this is possible with ONLY the doSelect method and no other logic. As Pier-Olivier said additional logic would need to be implemented on the returned data, or you can use RESTful web services which would allow you to filter in the way described above...

     

    If I wanted the contact that was last updated:

    http://<hostname>:<rest-port>/caisd-rest/cnt?SORT=last_mod_dt DESC&size=1

     

    Or the first contact created with a type of Customer:

    http://<hostname>:<rest-port>/caisd-rest/cnt?WC=type%3D'2310'&SORT=creation_date ASC&size=1

     

    More information on REST can be found at the links below:

    REST HTTP Methods

    Where Clause Resource Search

    Search Result Sorting

    http://https//docops.ca.com/ca-service-management/14-1/en/reference/ca-service-desk-manager-reference-commands/technical-reference/rest-http-methods



  • 4.  Re: Use "do select" method to return the last record of the query

    Posted Aug 08, 2016 06:36 PM

    I almost sure that this is not possible. But if you need to get some particular record in one web services call you can write your own spell and call it using callServerMethod. More info can be found here: SPEL: How to call SDM method using WebServies



  • 5.  Re: Use "do select" method to return the last record of the query

    Posted Aug 08, 2016 10:18 PM

    One way to approach this might be to add something like this:

    'and <column> = (select max(<column>) from <target table> where <other relevant conditions>)'

    ...to your select statement.  Can you share with us the query that you are trying to retrieve the last record from?

     

    Regards,

    James



  • 6.  Re: Use "do select" method to return the last record of the query

    Posted Aug 09, 2016 05:33 AM

    Hi.

    You may use DoQuery to get a list handle and the count of records found, instead of DoSelect.

    Then you would be able to access the last record values by using GetListValues method

    Nevertheless, I still don't see a chance to influence the sort order using soap services

    And never ever forget to free up the list handle by using the FreeListHandles method

    Regards

    .............Michael