Salesforce SOAP API: How to Call Utility Functions using SOAP API


Running bulk insert or update jobs to add or update Salesforce Records is common practice and it is also not uncommon to see Data Synchronization Processes getting confused if the available solution is failed to update the exact time of Salesforce Record getting added or updated.

To solve this common challenge Salesforce offers a function getServerTimeStamp(). This function always returns the system current date time stamp in coordination with the UTC time zone, which implies that the local system would display the result according to the local time zone settings.

In this article, we see how we can query system current date-time using a SOAP API call.

Prepare Request Object


In this section, we will see how we can prepare the request envelope to pass it as an object to SOAP API Endpoint.

Step-1: We need to pass the Session-Id under Session Header Tag. This Session-Id is required to authorize the SOAP API request against the Salesforce Org.

To know about retrieving Session-Id, You can read one of my earlier article Salesforce SOAP API Authentication: The Login Request

Step-2: Then we need to specify the API version of getServerTimestamp() method as shown in the screenshot below-


Analyze Response Object


In this section will analyze the Response Object and see the expected outcome-
<type> tag under <limitInfo> provide the details on the Governor Limits KPI, in this demo it is “API Requests” which implies that values in <current> & <limit> tags (Explained in Step-3 & Step-4 below) contains values about API Request issued or can be issues to Salesforce Org.

Step-3: Under the <limitInfo> tag we can see <current> tag that represents the total number of API requests issued so far against the Salesforce Org Governor Limits. In this case, the value is 50.

Step-4: Under the <limitInfo> tag we have another child tag <limit> that represents the total number of permissible API requests that can be issued as per the governor limit of the target Salesforce Org. In this case, the value is 1500.

Step-5: Under <getServerTimestampResponse> tag, we have another child tag <result>. In this tag, we will get the result of our request as a date time stamp string showing system current date & time based on local system time zone settings.


Hope you enjoyed this article. Please leave your comments to let me know how you do like the content and how you do find it helpful to learn the topic.

Comments