Using API, how to retrieve a list of CRs based on a Usr_ defined field

Hi All,


I'm looking for a way to make a call through the API to query the Starteam DB and have the query return a list of CRs that have a matching value in a Usr_ defined field.


For example, for each CR we have a Usr_ReleaseNumber text field defined for the CR. I would like to send a query that basically says, "Please return a list of CR's that contain Usr_ReleaseNumber equal to "1234". I'd like to see the work done on the database side, rather than have to walk a list of CR's in the folder and interrogate each one to see if it has a matching release number.


Is this something I can do using the ViewMemberListManager? If so, still not sure how to construct the query through the API to return just the relevant CRs.


Thank you!!

  • the simplest query you can write is one using the CommandProcessor class, which encapsulates viewmemberlistmanagers, folderlistmanagers, sorting, querying, filtering etc.

    a pseudo query would look like this
    Server s = new Server("host", port);
    Project p = s.findProject("projectname");
    View v = p.findView("viewname);
    CommandProcessor cp = new CommandProcessor(v);
    String[][] results = cp.execute("select viewmemberid from changerequest where Usr_ReleaseNumber = "1234"");
    // do something with the results

    I hope this helps

  • In reply to Anil Peres-da-Silva:

    Thank you Anil, it helped immensely!!
  • In reply to jlynch:

    Anil - if I wanted to add an additional parameter to the execute query and search on the Property "ClosedOn", would it look like this:

    String[][] results = cp.execute("select viewmemberid from changerequest where Usr_ReleaseNumber = "1234" and ClosedOn >= '01/01/2019'");

    What date format is accepted? Thank you for your response.
  • In reply to mzrousar:

    Yes, you can execute any query through the CommandProcessor which is supported by the stcmd/stcmdEx engine.
    The entire syntax of the select statement is available here
    You have the flexibility to provide the date format of your choice, per the rules of the grammar (-pattern)  in the link above.
    (though for what its worth, the format is validated using the java SimpleDateFormat pattern matcher)
    Take care