getDeleted
Retrieves the list of individual objects that have been deleted within the given timespan for the specified object.
Syntax
GetDeletedResult = sfdc.getDeleted(string sObjectType dateTime startDate dateTime EndDate);Usage
Use getDeleted for data replication applications to retrieve a list of object instances that have been deleted from your organization's data within the specified timespan. The getDeleted call retrieves a GetDeletedResult object that contains an array of
DeletedRecordobjects containing the ID of each deleted object and the date/time (GMT timezone) on which it was deleted. Be sure to read Data Replication before using getDeleted in your client applications.:: Note
The getDeleted call retrieves the IDs of all deleted objects for the given object throughout the organization, including data that is outside of the user's sharing model.
Rules and Guidelines
When replicating deleted objects, consider the following rules and guidelines:
- The specified startDate must chronologically precede the specified endDate value. The specified startDate cannot be the same value as, or later than, the specified endDate value. Otherwise, the sforce Web service returns an
INVALID_REPLICATION_DATEerror.- Client applications typically poll for changed data periodically. For important polling considerations, see Polling for Changes.
- Certain objects cannot be replicated via the sforce API. To replicate an object via the getDeleted call, its object must be configured as replicateable (
replicateable=True). To determine whether a given object can be replicated, your client application can invoke the describeSObject call on the object and inspect its replicateable property.- Development tools differ in the way that they handle time data. Some development tools report the local time, while others report only the GMT time. To determine how your development tool handles time values, refer to its documentation.
Basic Steps for Replicating Deleted Objects
Replicating objects involves the following basic steps for each object that you want to replicate:
- Optionally, the client application determines whether the structure of the object has changed since the last replication request, as described in Checking for Structural Changes in the Object.
- Call getDeleted, passing in the object and timespan for which to retrieve data.
- In the GetDeletedResult object, iterate through the returned array of
DeletedRecordobjects containing the ID of each deleted object and the date/time (GMT timezone) on which it was deleted.- Your client application must then take the appropriate action on the local data to remove (or flag as deleted) the deleted objects. If your client application cannot match rows in the local data using the retrieved object ID, then it must call retrieve, passing in the ID, to obtain the information it needs to match the rows in the local data to delete.
- Optionally, the client application saves the request timespan for future reference.
A client application likely performs other tasks associated with data replication operations. For example, if an opportunity were to become closed, a client application might run a new revenue report. Similarly, if a task were completed, the process might log this somehow in another system.
Sample Code-Java
private void getDeletedSample() { //You can use the timestamp from the service for a known point in time Calendar serverTime = binding.getServerTimestamp().getTimestamp(); //Create a start time value for the call GregorianCalendar startTime = (GregorianCalendar) serverTime.clone(); //Create an end time value for the call GregorianCalendar endTime = (GregorianCalendar) serverTime; //Subtract 5 mins from the server time so that we have a valid time frame. //You can use just about any timespan you want, 5 minutes is arbitrary endTime.add(GregorianCalendar.MINUTE, -5); GetDeletedResult gdr = binding.getDeleted("Contact", (Calendar)startTime, (Calendar)endTime); //Check the number of records contained in the results, if more that 0, //then something was deleted in the 5 minute span if (gdr.getDeletedRecords().length > 0) { for (int i=0;i<gdr.getDeletedRecords().length;i++) { System.out.println(gdr.getDeletedRecords(i).getId().getValue() + " was deleted on " + gdr.getDeletedRecords(i).getDeletedDate().getTime().toString()); } } else { System.out.println("No deletions from contacts in the last 5 minutes."); } }Sample Code-C#
private void getDeletedSample() { DateTime endTime = binding.getServerTimestamp().timestamp; DateTime startTime = endTime.Subtract(new System.TimeSpan(0, 0, 5, 0, 0)); sforce.GetDeletedResult gdr = binding.getDeleted("Contact", startTime, endTime); if (gdr.deletedRecords.Length > 0) { for (int i=0;i<gdr.deletedRecords.Length;i++) { Console.WriteLine(gdr.deletedRecords[i].id + " was deleted on " + gdr.deletedRecords[i].deletedDate.ToString()); } } else { Console.WriteLine("No deleted contacts between " + startTime.ToString() + " and " + endTime.ToString() ); } }Arguments
Name Type Description sObjectType string Object. The specified value must be a valid object for your organization. For a complete list of sforce objects, see List of sforce Objects. startDate dateTime Starting date/time (GMT-not local-timezone) of the timespan for which to retrieve the data. The sforce Web service ignores the seconds portion of the specified dateTime value (for example, 12:30:15 is interpreted as 12:30:00 GMT). endDate dateTime Ending date/time (GMT-not local-timezone) of the timespan for which to retrieve the data. The sforce Web service ignores the seconds portion of the specified dateTime value (for example, 12:35:15 is interpreted as 12:35:00 GMT).
Response
Faults
See Also
|
© Copyright 2000-2003 SalesForce.com, Inc. |