[SalesForce] Get translation of “Salutation” via Metadata API

Through the metadata API it is possible to query the translations of a Picklist field.
In our scenario the relevant objects are Lead and Contact.
We were able to get the translations except for the Salutation.
The Salutation is not part of the result set.

As you can see on the “Leads Fields” page, the Picklist "Salutation" seems to be somehow in a hierarchy with the "name" field.
enter image description here
Is this relevant for the query?

As far as I know the only Compound data types are Address and Location…

Here is the code we use to query the metadata API:

MetadataConnection connection = createMetadataConnection( USER, PASS );

    ReadResult result = connection.readMetadata( "CustomObjectTranslation", new String[] { "Lead-de" } );
    for( Metadata data : result.getRecords() )
    {
        CustomObjectTranslation objectTranslation = (CustomObjectTranslation)data;
        for( CustomFieldTranslation fieldTranslation : objectTranslation.getFields() )
        {
            if( fieldTranslation.getPicklistValues().length > 0 )
            {
                System.out.println( "Field: " + fieldTranslation.getName() );
                for( PicklistValueTranslation value : fieldTranslation.getPicklistValues() )
                    System.out.println( "   " + value.getMasterLabel() + " -> " + value.getTranslation() );
            }
        }
    }

The outcome (short version)

Field: Rating
   Cold -> Kalt
   Hot -> Heiß
   Warm -> Warm

But there is nothing in the result set for the "Salutation".
Is it possible that it is impossible to get the translations for the "Salutation" via the metadata API?

Thanks

Best Answer

The salutation picklist values and so the translations are somehow shared between objects (Lead, Contact, CampaignMember). You will also notice it when you modify a value/translation in one of the objects through the UI that it will be reflected in the other objects.

CampaignMember is the (only) object where the values are accessible through the metadata API.

Sadly this is not obvious in the first place and also not well documented. But makes sense in order to remove duplication between the salutations for different objects.

Query the salutation metadata through the CampaignMember object should do the trick:

ReadResult result = connection.readMetadata( "CustomObjectTranslation", new String[] { "CampaignMember-de" } );
    for( Metadata data : result.getRecords() )
    {
        CustomObjectTranslation objectTranslation = (CustomObjectTranslation)data;
        for( CustomFieldTranslation fieldTranslation : objectTranslation.getFields() )
        {
            if( "Salutation".equals( fieldTranslation.getName() ) )
            {
                System.out.println( "Field: " + fieldTranslation.getName() );
                for( PicklistValueTranslation value : fieldTranslation.getPicklistValues() )
                    System.out.println( "   " + value.getMasterLabel() + " -> " + value.getTranslation() );
            }
        }
    }

Should return something like:

Field: Salutation
   Dr.   -> Dr.
   Mr.   -> Herr
   Mrs.  -> Frau
   Ms.   -> Frau
   Prof. -> Prof.
Related Topic