1 Reply Latest reply on Oct 9, 2012 8:19 AM by Cristinas-Oracle

    Correct way to use UseChildAnd() function.

      I am trying to make two separate queries using java:

      1. Opened Date AND Status
      2. Opened Date OR Status

      I found out that the setUseChildTrue() should help with that, but I guess i need to know how to use it. Here is the query part of my code:

                crmondemand.ws.serviceRequest.Default_Binding_ServiceRequest stub = req_getAndSetupServiceRequestStub(urlAddr, userName, passWord);

                // creates the input and output message objects
                // Create object to hold Query information.
                crmondemand.ws.serviceRequest.ServiceRequestWS_ServiceRequestQueryPage_Input serviceRequestlist = new crmondemand.ws.serviceRequest.ServiceRequestWS_ServiceRequestQueryPage_Input();
                // Create array of objects to hold records.
                crmondemand.ws.serviceRequest.ServiceRequestWS_ServiceRequestQueryPage_Output srOutlist = new crmondemand.ws.serviceRequest.ServiceRequestWS_ServiceRequestQueryPage_Output();
                // Create array to hold single Query.
                crmondemand.xml.serviceRequest.ServiceRequest[] serviceRequests = new crmondemand.xml.serviceRequest.ServiceRequest[2];
                // Create object to hold single record, which defines the Query.
                crmondemand.xml.serviceRequest.ServiceRequest serviceRequest1 = new crmondemand.xml.serviceRequest.ServiceRequest();
                // return these fields in the output message
                if(argOpenDateStart.equals("") && argOpenDateEnd.equals("")){
                else if(argOpenDateStart.length()>1 && argOpenDateEnd.equals("")){
                     serviceRequest1.setOpenedTime(">= '" + argOpenDateStart + "'");
                else if(argOpenDateStart.length()>1 && argOpenDateEnd.length()>1){
                     serviceRequest1.setOpenedTime("(>= '" + argOpenDateStart + "') AND (<='" + argOpenDateEnd + "')");
                else if(argOpenDateStart.equals("") && argOpenDateEnd.length()>1){
                     serviceRequest1.setOpenedTime("<= '" + argOpenDateEnd + "'");
                // Put single Query in Querylist (that can hold only 1 query).
                serviceRequests[0] = serviceRequest1;

                serviceRequestlist.setListOfServiceRequest(serviceRequests); // Put list of Queries in QueryPage_Input
                serviceRequestlist.setPageSize(Integer.toString(PAGESIZE)); // Set the 'n' number of serviceRequests you want to get. Max. is 100.
                serviceRequestlist.setStartRowNum(Integer.toString(startRowNumber)); // starting at row 0
                serviceRequestlist.setUseChildAnd("false"); //??

                // invoke serviceRequestQueryPage using the serviceRequestlist input message
                srOutlist = stub.serviceRequestQueryPage(serviceRequestlist);

      Any help or suggestion is greatly appreciated.
        • 1. Re: Correct way to use UseChildAnd() function.

          the UseChildAnd is used to add to the query criteria attributes from the child records.
          For all Oracle CRM On Demand object methods (except Attachment), it is possible to query using one
          operation within a parent-child relationship. This type of query is called Query By Children. The query
          can be assembled using parent attributes as well as child attributes. You can query for all children
          of a particular parent or set of parents, all parents of a particular child or set of children, or for both
          parents and children of a particular set.
          NOTE: When performing a query using Query By Children, certain fields on a child object might not
          be filterable.
          Not all child objects are filterable in Web Services v1.0 (for example, the Partner child of
          CAUTION: This type of query performs slowly and must only be used when necessary.
          As an example of how you can search for parent records using criteria on a child:
          This query would return all contacts where the first name is John and at least one of John’s addresses
          is for Canada. The child criteria are appended to the parent using an AND or OR operator based on
          the value of the argument UseChildAnd. When UseChildAnd is true, the child criteria are “ANDed”,
          otherwise they are “ORed”.