Retrieves the list of individual objects that have been updated (added or changed) within the given timespan for the specified object.
GetUpdatedResult[] = connection.getUpdated(string sObjectType, dateTime startDate, dateTime EndDate);
Use getUpdated() for data replication applications to retrieve a set of IDs for objects of the specified object that have been created or updated within the specified timespan. The getUpdated() call retrieves an array of GetUpdatedResult objects containing the ID of each created or updated object and the date/time (Coordinated Universal Time (UTC) time zone) on which it was created or updated, respectively. Be sure to read Data Replication before using getUpdated() in your client application.
When replicating created and updated objects, consider the following rules and guidelines:
Replicating objects involves the following basic steps for each object that you want to replicate:
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.
public void getUpdatedRecords() { try { Calendar serverTime = connection.getServerTimestamp().getTimestamp(); GregorianCalendar startTime = (GregorianCalendar) serverTime.clone(); GregorianCalendar endTime = (GregorianCalendar) serverTime; // Subtract 60 minutes from the server time so // that we have a valid time frame, you can use just // about any timespan you want, 60 minutes is arbitrary. startTime.add(GregorianCalendar.MINUTE, -60); System.out.println("Checking updates as of: " + startTime.getTime().toString() ); GetUpdatedResult ur = connection.getUpdated("Account", startTime, endTime); System.out.println("GetUpdateResult: " + ur.getIds().length); if (ur.getIds() != null && ur.getIds().length > 0) { for (int i = 0; i < ur.getIds().length; i++) { System.out.println(ur.getIds()[i] + " was updated between " + startTime.getTime().toString() + " and " + endTime.getTime().toString() ); } } else { System.out.println("No updates to accounts in " + "the last 60 minutes." ); } } catch (ConnectionException ce) { ce.printStackTrace(); } }
private void getUpdatedSample() { DateTime endTime = binding.getServerTimestamp().timestamp; DateTime startTime = endTime.Subtract(new System.TimeSpan(0, 0, 5, 0, 0)); sforce.GetUpdatedResult gur = binding.getUpdated("Account", startTime, endTime); if (gur.ids.Length> 0) { for (int i=0;i<gur.ids.Length;i++) { Console.WriteLine(gur.ids[i] + " was updated between " + startTime.ToString() + " and " + endTime.ToString()); } } else { Console.WriteLine("No updates to accounts between " + startTime.ToString() + " and " + endTime.ToString() ); } }
| Name | Type | Description |
|---|---|---|
| sObjectTypeEntityType | string | Object type. The specified value must be a valid object for your organization. For a list of standard objects, see Standard Objects. |
| startDate | dateTime | Starting date/time (Coordinated Universal Time (UTC) time zone—not local— timezone) of the timespan for which to retrieve the data. The API ignores the seconds portion of the specified dateTime value (for example, 12:30:15 is interpreted as 12:30:00 UTC). |
| endDate | dateTime | Ending date/time (Coordinated Universal Time (UTC) time zone—not local— timezone) of the timespan for which to retrieve the data. The API ignores the seconds portion of the specified dateTime value (for example, 12:35:15 is interpreted as 12:35:00 UTC). |