Search in sources :

Example 1 with UndeleteResult

use of com.salesforce.soap.partner.UndeleteResult in project tdi-studio-se by Talend.

the class PartnerSamples method undeleteSample.

private void undeleteSample() {
    // call the login function to do so
    if (!loggedIn) {
        if (!login()) {
            return;
        }
    }
    // For this sample we will create an account and then delete it
    // to demonstrate the power of queryAll
    String accountName = getUserInput("\nEnter a name for a test account:");
    if (accountName == null || accountName.length() == 0) {
        return;
    }
    String accountId = createAndDeleteAnAccount(accountName);
    getUserInput("You can check your recycle bin now to see the deleted account.\nHit return to continue...");
    // Now, we can undelete the account
    try {
        UndeleteResult udr = binding.undelete(new String[] { accountId })[0];
        if (udr.isSuccess()) {
            System.out.println("The account was successfully undeleted.");
            System.out.println("If you check your recycle bin you will see the account is no longer present.");
        } else {
            System.out.println("Undelete failed: " + udr.getErrors(0).getMessage());
        }
    } catch (ApiFault e) {
        System.out.println("Error un-deleting test account: " + e.getExceptionMessage());
    } catch (RemoteException e) {
        System.out.println("Error from the server on create test account: " + e.getMessage());
    }
    getUserInput("\nHit return to continue...");
}
Also used : ApiFault(com.salesforce.soap.partner.fault.ApiFault) UndeleteResult(com.salesforce.soap.partner.UndeleteResult) RemoteException(java.rmi.RemoteException)

Aggregations

UndeleteResult (com.salesforce.soap.partner.UndeleteResult)1 ApiFault (com.salesforce.soap.partner.fault.ApiFault)1 RemoteException (java.rmi.RemoteException)1