Saturday, March 25, 2023

How to Query Salesforce Objects from External System Without Code

Sometimes, external system wants to get the latest data from Salesforce to run the business logic in their system. In those cases, external system can do a simple query Salesforce objects with the help of Salesforce Standard APIs. There is no code required from a Salesforce developer

Lets understand this concept with an example.

Consider Workbench as a external system. To query salesforce objects in workbench we need to follow the below pattern:

 /services/data/v20.0/query?q=SELECT+Id+,+Name+FROM+USER

where every element is concatenated by + operator

After the query is added click on Execute and once the response comes then click on Show Raw Data. It will open up the blue screen on the right.

workbench


  • totalsize attribute is the number of records returned.
  • At a time workbench can display 2000 records under raw response.
  • If the number of records returned are more than 2000 then NextRecordsUrl will be used to get next set of 2000 records.
  • Done Attribute under raw response tells whether we have reached the last page or not. 
  • If done = false then we need to NextRecordUrl to get next records.
  • If done = false, that mean there are no more records after this.

We can also write where clause in the query
SELECT+Id+,+Name+FROM+USER+where+id+=+'+00500xx+'
Similarly, we can add any filter in the query and get back the response.


Let me know your thoughts on this and we can discuss more.

No comments:

Post a Comment