Learning Objective:-
This unit describes:-
- What is the operation query and how it works?
- What is pullQuery and how it works?
What is a Query? #
Query means querying data from salesforce from a client by using Soap UI or postman and when we use postman we use rest version and for soap, we use search service API. Querying data is using SOQL statement, We can write SOQL by entering into the outbound interface or using the query editor and this way we can generate SOQL statements in our outbound interface.
It gives the response as a JSON to the client if we call using Soap UI or by the postman, we can put different conditions or requests. But the main reason or requirement is query data.
1.1 We have 2 possibilities for query operation:- #
1. Query operation without mapping will give raw data as a result.
2. Query operation with mapping will give enhanced data as a result.
1.2 How does query works? #
The procedure is given below:-
Pre-Requisite :-
- Create Metadeta provider.
- Create Istructure Repository.
- Create Message type e.g AccountMT is the parent of ContactMT.
- Create Integration.
1. Create Outbound Interface then select Status is Deployed and Operation Type with Query (As shown in the picture given below):-
2. Add Metadata Provider, Istructure Repository, Message Type for interface(As shown in the picture given below):-
3. Do tree mapping field Salesforce object map with Message Type step by step with the level (As shown in the picture given below):-
4. Navigate to Postman application.
5. Create a new request and a new folder.
6. Change method GET to POST and enter Salesforce classic URL with /services/apexrest/skyvvasolutions/SearchService (shown in the picture given in point 8).
7.Click Body tab => click raw tab => select JSON (application/json) in picklist => Create rest body
The body is shown below in the picture.
{
"INTEGRATIONID" : "xxxxxxxxxxxx",
"INTERFACENAME" : "xxxxxxxxxxxx"
}
8. Click Header tab => enter Authorization for Key cell => create Bearer with sessionId.
(As shown in the picture given below).
9. Click Send button to get response data.
10. Here is the result of the responded JSON data.
What is pullQuery? #
When we query data we get a result and then next time we query again we get the same result and it sends to the client again. So the pullQuery is used in combination with an outbound interface and it is used within interface outbound scheduler, we have a schedule that can execute the outbound interface, select the data and send the data to the receiver. Here we use pullQuery operation like we don’t want to send save data again which is sent once already. So by this pullQuery operation, we will send data only once. For this, we need to create a custom field on account salesforce object.
2.1 How does pullQuery works? #
The procedure is given below:-
Pre-Requisite:-
- Create Integration.
- Create Adapter- SFDC2SAPPI.
1. Create an Outbound interface:- #
- Interface Direction – “OutBound”.
- Operation Type – “pullQuery”.
- Click on Query Editor
- Enter Query as per requirement.
- Save SOQL.
- Select Inbound Interface ID in “Response Interface”.
- Select Outbound Adapter.
- Select Invoke Outbound/Inbound Interface.
- Select Processing mode – “Asynchronous”
- Click on Do Mapping.
- Save Mapping.
2. Create an Inbound interface:- #
- Interface Direction – “Inbound”.
- Operation Type – “Upsert”.
- Click on Do Mapping.
- Create Formula in the sentToSAP field.
- Click on Save.
- Run the “Interface Execution Scheduler”.
Open Developer Console and run the code given below:- #
skyvvasolutions.CallOutControl c=new skyvvasolutions.CallOutControl();
c.returnxml=true;
c.returnListRecord=true;
c.iscreatemessage=true;
List<String> lId = new List<String>();
lId.add(‘0017F000009gT11QAE’);
for(Account a : [SELECT Id FROM Account]){
lId.add(a.Id);
}
skyvvasolutions.IServices.invokeCallout2(‘PullQuery’,’Outbound’,lId,’SYNC’, c);
Check the result in Message Monitoring:- #