You need to sign in to do that
Don't have an account?
Héctor Martinez Moltó
Update managed CustomObjectTranslation with Metadata API (Apex)
I'm trying to update CustomObjectTranslation components with a callout to the Metadata API through Apex and I have been able to accomplish the task for my own custom objects and managed fields from standard objects. The problem is when trying to update those custom objects that come from a managed package. When list the Metadata I can see those components there, but seems like when I try to read them it doesn't returns anything, with or without namespace, I think I've tried everything.
I'm starting to think it's just not possible to read a managed CustomObjectTranslation, although I have no problem when doing the same with CustomObject or CustomField, It's just the translations from managed custom objects that I'm not able to update.
I've been searching the net without success for the last week. Hope somebody knows what I'm doing wrong or just if it can tell me that it's just not possible to do (although if that's the case retrieving that same component with a tool like Ant shouldn't work either and it does).
I'm starting to think it's just not possible to read a managed CustomObjectTranslation, although I have no problem when doing the same with CustomObject or CustomField, It's just the translations from managed custom objects that I'm not able to update.
I've been searching the net without success for the last week. Hope somebody knows what I'm doing wrong or just if it can tell me that it's just not possible to do (although if that's the case retrieving that same component with a tool like Ant shouldn't work either and it does).
Checked it, and its definetly a bug in MDAPI. Custom Fields related to Custom Object are not returned in the response. Custom fields related to Standard Object are returned correctly.
It might not solve all use cases, but you dont need the fields if you know they exists - just read the CustomObjectTranslation and manually add them and update. It will correctly update translations.
Something like:
objectTranslation.fields = new CustomFieldTranslation[]{};
CustomFieldTranslation cft = new CustomFieldTranslation();
cft.name='Namespace__FieldName__c';
cft.label='New Label';
objectTranslation.fields.add(cft);