sforce logo

getUpdated


Retrieves the list of individual objects that have been updated (added or changed) within the given timespan for the specified object.

Syntax

GetUpdatedResult[] = sfdc.getUpdated(string sObjectType dateTime startDate 
dateTime EndDate); 

Usage

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 (GMT timezone) on which it was created or updated, respectively. Be sure to read Data Replication before using getUpdated in your client application.

:: Note

The getUpdated call retrieves the IDs only for objects to which the logged in user has access. For example, data that is outside of the user's sharing model is not returned.

Rules and Guidelines

When replicating created and updated objects, consider the following rules and guidelines:

Basic Steps for Replicating Updated Objects

Replicating objects involves the following basic steps for each object that you want to replicate:

  1. 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.
  2. Call getUpdated, passing in the object and timespan for which to retrieve data.
  3. Iterate through the returned array of IDs. For each ID element in the array, call retrieve to obtain the latest information you want from the associated object. Your client application must then take the appropriate action on the local data, such as inserting new rows or updating existing ones with the latest information.
  4. Optionally, the client application saves the request timestamp 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 getUpdatedSample() { 
    //You can use the server timestamp as 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 
    startTime.add(GregorianCalendar.MINUTE, -5);             
             
    System.out.println("Checking updates at: " + startTime.getTime().toString()); 
    GetUpdatedResult ur = binding.getUpdated("Account",  
                (Calendar)startTime, (Calendar)endTime); 
     
    //Check the length of the returned array of IDs  
    //to detect if you got any hits             
    if (ur.getIds().length > 0) { 
        for (int i=0;i<ur.getIds().length;i++) { 
            System.out.println(ur.getIds(i).getValue() + " was updated between " + 
startTime.getTime().toString() + " and " + endTime.getTime().toString()); 
        }     
    } else { 
        System.out.println("No updates to accounts in the last 5 minutes."); 
    } 
} 

Sample Code-C#

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() ); 
    } 
} 

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

GetUpdatedResult[]

Fault

InvalidSObjectFault

UnexpectedErrorFault

See Also

getDeleted

Data Replication

Sample SOAP Messages-getDeleted

Concepts


© Copyright 2000-2003 SalesForce.com, Inc.
All rights reserved • Various trademarks held by their respective owners.