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