Performance Best Practices for Web Service Implementations
Here are some best practices for optimal performance when working with web services.
Groovy Script
Use the Groovy script to call an external web service to sync data on creating a record in the application.
A "before update" trigger to call an external web service to sync data is a time-consuming process. The entire commit must wait for the web service response, impacting the total runtime performance.
Instead of doing this with triggers, you can write an Object Workflow that calls a groovy on the update of a record and syncs to the external system. This asynchronous method of syncing data with the external system will reduce the UI overhead.
REST/SOAP
You can set a field value to
NULL using web services. This example will set a Text_c field value to null, even if
it had a previously entered value:<ns2:Text_c>
</ns2:Text_c>
REST – Fetching Fields
Use Case | Solution |
---|---|
Query to return only specific fields |
Format for fields in child resource:
?fields=Accessor1:Attribute1,Attribute2 |
Query to return only data and no links | ?onlyData |
Sort the result returned by Query | ?orderBy=field1:asc,field2:desc |
Filtering the records on a generic expression | ?q=expression1 |
Filter records within a specific date range | To extract records filtering on the fields of type Date the parameter q= of the url should be: <Nameofthefield> >
YYYY-MM-DDTHH:MI:SS.sss-HH:MM |
Query to fetch records from a specified offset | ?offset=<number> |
Combining multiple conditions with AND effect | ?q=expression1;q=expression2 |
Combining multiple conditions with OR effect | ?q= expression1 OR expression2 Example: ?q= Type = ECO OR ChangeAnalyst = John Smith |
Filtering on check box fields | ?q=checkbox_c=Y |
Skip AND as a Keyword when present in a value | ?q=RecordName%20LIKE%20%27Fin%20And%20Mgmt%27 |
REST – Fetching Number of Records
You can use this limit parameter to limit the number of fields that are fetched for a REST call.?limit=<number>If you don't specify a number in this parameter, the limit is set to 25. But you can manually specify a limit value, so it will fetch that many records. The recommended limit value is 499 or lower, to maintain optimal performance. Don't use a higher limit value for fetching records, even if you've a few records, as memory is allocated based on the limit parameter value you set.
Performance Baseline MeasurementsMeasure the time it takes to render:
- Object Edit page
- Save and Close flow
- Save and Continue flow