3

Was working on some generic apex, and wrote a few lines of code to get the SOAPType of a field based on the type and the name. Went off, and worked on some other areas, and wrote something which used that code on a BillingAddress. I expected it to fail, but it provided to the correct type: ADDRESS.

Here's a snippet to replicate:

SObjectType internalDescribeType = Schema.getGlobalDescribe().get('Account');
Schema.SObjectField fieldDescribe = internalDescribeType.getDescribe().fields.getMap().get('BillingAddress');

System.debug(fieldDescribe.getDescribe().getSOAPType());

The debug output for this snippet will result in:

13:08:59:111 USER_DEBUG [33]|DEBUG|ADDRESS

But, neither the SOAPType enum or the DisplayType enum support this value. Is this intended undocumented behavior?

3

There are a very large number of SoapType values which are not contained in your linked document. When I investigated, I found 619.

system.debug(SoapType.values().size()); // yields 619
for (SoapType st : SoapType.values()) system.debug(st);

If you look through the logs, you will indeed see ADDRESS listed:

12:11:07:006 USER_DEBUG [2]|DEBUG|LOCATION
12:11:07:006 USER_DEBUG [2]|DEBUG|ADDRESS
12:11:07:006 USER_DEBUG [2]|DEBUG|MAP_ENTRY

Can't say I know what even half of them mean, but I can at least verify ADDRESS is a valid Enum value for SoapType.

| improve this answer | |
  • 2
    I also get 619 types when running that snippet, and of those types, 25 can be used with Type.forName(...), and 15 of those can be used with Type.newInstance(). Very interesting. – battery.cord Jun 17 '16 at 18:41
1

You may want to look at the documentation for SOAPType and refer to your WSDL to see what each field will return. All fields should return a type.

You may also want to check the documentation for SOAPType and FieldTypes

So if you look at BillingAddress in the WSDL you will get the TNS type ADDRESS as the return.

<element name="BillingAddress" nillable="true" minOccurs="0" type="tns:address"/>

Also a little more testing, it is just tns:address, tns:ID and tns:anytype fields that I've found to return values. Others in the Field Types list might not, so I would suggest testing on your org.

| improve this answer | |
  • 1
    The point of this question is that some of these SOAPType exist, but are not in the documentation. What is interesting, and I would have failed to notice this if not for your answer, is that the <simpleType name="soapType"> tag has the values from the documentation, as well as address and location, plus some other urn values. – battery.cord Jun 17 '16 at 18:39
  • 1
    @battery.cord The documentation isn't necessarily authorative. For example, I once enumerated every object type by Id hack and found a ton of things that are not in a document anywhere. – sfdcfox Jun 17 '16 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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