Skip to main content
1-Visitor
Feb 3, 2017 11:26 AM UTC
Question

Anyone knows how to get items with customquery in C#? using PTC web service

Hi I am struggling to get items with getItemsByCustomQuery

Please find below code,

MKSService.getItemsByCustomQuery cusQ = new getItemsByCustomQuery();

MksIntegration.MKSService.CustomQuery qry = new CustomQuery();

  MKSService.Integrity_2009Client cl = new Integrity_2009Client();

       string DateStr = "2014-10-29";

       qry.QueryDefinition = "Modified Date = " + DateStr;

       qry.Username = "XXXXXX";

       qry.Password = "XXXXXX";

       string[] field1 = new string[] { "id", "Summary", "Modified Date" }; //

       qry.InputField = field1;

       cusQ.arg0 = qry;

      getItemsByCustomQueryResponse qryRes = new getItemsByCustomQueryResponse();

     qryRes = cl.getItemsByCustomQuery(cusQ);

Appreciate your response

Thanks

    5 replies

    16-Pearl
    Feb 3, 2017 2:22 PM UTC

    Hello Santosh Bhosale‌,

    You might want to look at one of the code samples in the Sample Code Knowledge Hub for Integrity.  You might also want to look at the article Integrity: How to build a custom query.

    Is that helpful at all?

    Kind Regards,

    Kael

    Translate
    sbhosale1-VisitorAuthor
    1-Visitor
    Feb 3, 2017 3:21 PM UTC

    Hi Kael,

    Thanks for your reply.

    I checked the links shared by you. But the sample code is for creating the new item. I want to search or get the item of particular date or between date. I am able to retrieve the data of supplied ID, but problem is with Modified Date and Created Date. I want to query the items of particular date. And second link doesn't explains anything.

    Best Regards,

    Santosh

    Translate
    16-Pearl
    Feb 13, 2017 8:21 PM UTC

    Hello Santosh Bhosale‌,

    Jim Bates‌ comment below points you in the right direction.

    Kind Regards,

    Kael

    Translate
    1-Visitor
    Feb 7, 2017 2:02 PM UTC

    The syntax for searching by date isn't quite as obvious as it could be. There are several options available, however the one that I believe that you're looking for is:

    Modified Date between Oct 29, 2014 and Oct 29, 2014

    You have other options such as:

    Modified Date today

    Modified Date yesterday

    Modified Date in the last 7 days

    When I have to create queries to use through the API, CLI, web service, etc, especially where the syntax isn't obvious, I create them using the GUI first, save the query, then use the CLI to view the query definition to get the proper syntax. I then use that syntax as the basis for creating a dynamic query in code.

    Also, be aware of timezone differences. When using the API you may find that all date values are returned in UTC values, and require conversion.

    Translate
    sbhosale1-VisitorAuthor
    1-Visitor
    Feb 15, 2017 11:54 AM UTC

    Hey Jim,

    Thanks for your inputs. Its working. 

    Translate