Example - Query - Java API
The sample code in this example shows a query executed in the W42101C form. This query attempts to match the following specified conditions:
Line Number equal to 2.
Requested Date within the last 2 years.
Sold To between 7000 and 8000.
Company is one of the values in the list "00070,00077".
The response will contain the JSON for the form with the matching records in the grid.
public void queryP42101() throws Exception
{
loginEnv.getUsedCapabilities().add("query");
FormRequest formRequest = new FormRequest(loginEnv);
formRequest.setFormName("P42101_W42101C");
formRequest.setReturnControlIDs("350|360|41[129,130,116,125]");
formRequest.setFormServiceAction(formRequest.ACTION_READ);
formRequest.setFindOnEntry("TRUE");
formRequest.setMaxPageSize("20");
Query query = new Query(loginEnv);
//auto find
query.setAutoFind(true);
//match all
query.setMatchType(Query.MATCH_ALL);
//clear any defaulted filters
query.setAutoClear(false);
//line number equals 2
NumberCondition condN = query.addNumberCondition("41[129]", NumericOperator.EQUAL());
condN.setValue(2);
//Requested Date within two years from today
DateCondition condD = query.addDateCondition("41[116]", DateOperator.GREATER());
condD.setSpecialDateValue(DateSpecialValue.TODAY_MINUS_YEAR(), 2);
//Sold To 125
BetweenCondition condST = query.addBetweenCondition("41[125]");
condST.setValues("7000", "8000");
//company in list
ListCondition list1 = query.addListCondition("360");
list1.addValue("00070");
list1.addValue("00077");
//set it in the request
formRequest.setQuery(query);
ObjectWriter writer = loginEnv.getObjectMapper().writerWithDefaultPrettyPrinter();
out.println(writer.writeValueAsString(formRequest));
String response = JDERestServiceProvider.jdeRestServiceCall(loginEnv, formRequest, JDERestServiceProvider.POST_METHOD, JDERestServiceProvider.FORM_SERVICE_URI);
}