I want to execute a SOQL by using Camel Salesforce component salesforce:query API for retrieving SObject Contact(s) by using AccountId. But it only return a DTO Contact which all fields are null. And I have debugged with Camel Salesforce component source code, and I found it got the Response with code 200.
BTW, does anyone know how to implement a dynamic SOQL, I found I cannot use ${body} in it, say, "sObjectQuery=SELECT LastName FROM Contact WHERE AccountID='${body}'"
- It is a simple maven project
- DTOs: Contact, Account have been generated by camel-salesforce-maven-plugin
- Other Camel Salesforce component REST API: salesforce:upsertSObject, salesforce:getSObjectWithId, salesforce:deleteSObjectWithId and salesforce:createSObject can be run and returned the correct results
Route:
from("direct:query")
.to("salesforce:query?sObjectQuery=SELECT LastName FROM Contact&sObjectClass="+ Contact.class.getName())
.process(exchange -> {
Object body = exchange.getIn().getBody();
System.out.println(body.getClass());
System.out.println(body);
});
ProducerTemplate template = camelCtx.createProducerTemplate();
Object obj = template.requestBody("direct:query", null, Object.class);
Actual Result: class com.salesforce.test.Contact {"Reporting_States__c":null,"Specialty__c":null}
Expected Result: return a QueryRecordsContact object which contains a fields of Contact List. (QueryRecordsContact is a DTO which was generated by Camel Salesforce maven plugin)