function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mc1392mc1392 

using java retrieve

Im not sure how to create the "Account" object in this sample code.

Java gives me an error on the instantiation on the object called "Account".

 

 

private void retrieveSample() { try { // Invoke the retrieve call and save results in an array of SObjects SObject[] sObjects = binding.retrieve("Id, AccountNumber, Name, Website", "Account", new ID[] {new ID("001x0000002kuk1AAA"), new ID("001x0000002khE0AAI")}); // 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) { // Loop through the array and print out some properties for (int i=0;i<sObjects.length;i++) { // Cast the SObject into an Account object Account retrievedAccount = (Account)sObjects[i]; System.out.println("Account: " + retrievedAccount.getId()); System.out.println(" AccountNumber = " + retrievedAccount.getAccountNumber()); System.out.println(" Name = " + retrievedAccount.getName()); System.out.println(" Website = " + retrievedAccount.getWebsite()); } } } catch (Exception ex) { System.out.println("An unexpected error has occurred." + ex.getMessage()); } }

 Do I need to import that object from a particular jar file?

Should I try making an SObject or a generic java Object?

 

SuperfellSuperfell
There should of been an Account object generated by WSDL2Java with the enterprise WSDL, perhaps you used the partner WSDL?
mc1392mc1392
Should I use "enterprise", if any?
SuperfellSuperfell
The code you're trying to run was written for the enterprise WSDL,so you'll need to use the enterprise WSDL to get it to work.
mc1392mc1392

Decided to just pass an array of strings into a select.