Skip to content

TestDataSupplementer misuses BindingSObject__c for custom SObjects #58

@goto-dev-null

Description

@goto-dev-null

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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions