-
Notifications
You must be signed in to change notification settings - Fork 53
Description
TestDataSupplementer acts like BindingSObject__c will always contain the developer name of the SObject, but that's not the case.
SObjectType sobjType = Schema.getGlobalDescribe().get( String.isNotBlank(tds_mdt.BindingSObject__c) ? tds_mdt.BindingSObject__c : tds_mdt.BindingSObjectAlternate__c );
For standard objects such as Account or Contact, BindingSObject__c
will just be "Account" or "Contact" respectively, which is no problem.
But if the BindingSObject__c is not standard, that field value contains an ID for the Entity Definition like "01I1k00000143aP", and because the global schema describe is keyed by DeveloperName, sobjType
will always be null.
So what we are really looking for is bindingConfig.BindingSObject__r.QualifiedApiName
but this is not accessible in TestDataSupplementer.cls due to using di_Injector.Org.Bindings.byName(ITestDataSupplement.class.getName()).get()
to retrieve the MDT.
That's the extent of the problem as I see it. The workaround is obviously to use BindingSObjectAlternate__c. I don't know another solution up front, unless there's a way to get an SObjectType
by its 01I
ID.