Ajax (1) Apex Class (12) Apex Trigger (2) Community (2) Home Page (1) HTML (4) Integration (3) JS (7) KB (1) Label (1) Licenses (1) Listing (1) Log (1) OOPs (5) Sharing (1) Static Resource (1) Test Class (3) URI (1) Visualforce (10)

Tuesday 3 June 2014

retrieveRecords using java

Sample Code—Java

This sample retrieves the Id, Name, and Website of the specified Account records. It writes the fields of the retrieved records to the console.

    public void retrieveRecords(String[] ids) {     try {        SObject[] sObjects = connection.retrieve("ID, Name, Website",              "Account", ids);        // Verify that some objects were returned.        // Even though we began with valid object IDs,        // someone else might have deleted them in the meantime.        if (sObjects != null) {           for (int i = 0; i < sObjects.length; i++) {              // Cast the SObject into an Account object              Account retrievedAccount = (Account) sObjects[i];              if (retrievedAccount != null) {                 System.out.println("Account ID: " + retrievedAccount.getId());                 System.out.println("Account Name: " + retrievedAccount.getName());                 System.out.println("Account Website: "                       + retrievedAccount.getWebsite());              }           }        }     } catch (ConnectionException ce) {        ce.printStackTrace();     }  }

No comments:

Post a Comment