Here in this tutorial, I am going to discuss query() and queryMore() operations in salesforce and how to invoke the same in a BPEL.
In my previous tutorials I have already discussed interaction with salesforce API using enterprise wsdl. Please refer those if you are new to use cases where salesforce has to be invoked directly.
I came across a scenario where I needed to retrieve data from a salesforce object. Query operation is a very easy way to do the same. Just a select query on the object and that is all. Please note that * is not used in sql query here. Specify all necessary field names that you want.
The query result object contains up to 500 rows of data by default. If the query results exceed 500 rows, then the client application uses the queryMore() call and a server-side cursor to retrieve additional rows in 500-row chunks.Moreover if you are querying for fields of type Base64, both query and query more returns a single record.
query()
query() call is used to retrieve data from an object and below are the parameters
INPUT-
1) queryString a query expression that specifies the object to query, the fields to retrieve, and any conditions that determine whether a given object qualifies.
Upon invocation, the API executes the query against the specified object, caches the results of the query on the API, and returns a query response object to the client application
OUTPUT-
1) done
type- Boolean
value-(true/false)
Description- Indicates whether additional rows need to be retrieved from the query results (false) using queryMore(), or not (true). Your client application can use this value as a loop condition while iterating through the query results.
2) queryLocator
Description- A specialized string, similar to ID. Used in queryMore() for retrieving subsequent sets of objects from the query results, if applicable.
3) Records
Description- Array of sObjects representing individual objects of the specified object and containing data defined in the field list specified in the queryString
4) Size
Type- int
Description-Total number of rows retrieved in the query.
queryMore()
INPUT-
1) queryLocator
OUTPUT-
Is same as that of query() operation.
Steps.
1) Create a SOA project with a BPEL and a reference with salesforce enterprise wsdl.
2) Invoke login operation and assign username and password
use session id, URL retrieved as response of login operation in subsequent operations as discussed in previous tutorials
3) Invoke query operation and create input and output variables. Input and Output of query operation looks like below
4) Assign sql query as input to query() operation
5) Create variables done,QueryLocator as string. Assign done and QueryLocator returned as response of query() operation to these variables.
6) Drop a While activity and enter the condition as done='false'.
7) Inside the while loop drop Invoke activity for queryMore operation and create input and output variables. Input and Output of query operation looks like below.
8) Assign value from QueryLocator variable to the input of queryMore operation.
9) After invoke assign done and QueryLocator returned as response of query() operation to these variables.
Deploy and test your composite.
HAPPY LEARNING!!!!
I really like and appreciate your post.Really thank you! Fantastic.
ReplyDeletesalesforce online training in hyderabad
salesforce online training hyderabad
It 's an amazing and awesome blog. Thanks for sharing
ReplyDeleteOracle Online Training
Oracle SOA Online Training Hyderabad