Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

When generating the jar via WSDL I see the fields are present on the custom object.
(e.g. MyCustomObj__c, field MyField__c), but when I generate the JAR (via the WSC tool) the resulting jar's does not allow access to this field.

e.g. I can do MyCustomObj__c obj = new MyCustomObj__c(); but obj.getMyField__c() is not defined.

(I'm using the Enterprise WSDL v34.0 and WSC 34.2.0, which are the latest as of time of writing)

How can I access this custom field?

share|improve this question
    
I dont think obj.getMyField__c() is valid method. What are you looking to achieve using that method ? –  Amit Bangad Jul 20 at 12:47
    
I want to access (get & set) the value of the custom field –  Nadav Greenberg Jul 20 at 14:00

3 Answers 3

To get field you would do something like that

// Java code
SObject contact = record; // Queried record by SOAP query method
Object firstName = contact.getField("FirstName");
Object lastName = contact.getField("LastName");
Object customfield = contact.getField( "My_Custom_Field__c");
share|improve this answer
    
unfortunately the method "getField" does not seem to exist in the JAR generated from the Enterprise WSDL. This is what I get: –  Nadav Greenberg Jul 20 at 13:55

That was a silly one - IntelliJ referred to a JAR that was generated with the WSDL prior to the creation of the custom object and its fields, thus couldn't find the relevant methods.

Once I cleared its caches and referred to updated JAR it works as expected:

To access the custom fields, as expected, obj.getMyField__c(); works just fine.

share|improve this answer

While the partner wsdl is coded using the generic SObject with getField() & setField(), the enterprise wsdl should generate classes for your actual objects and fields in your org.

Instead you would use obj.getFieldName().

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.