fflib-apex-common
fflib-apex-common copied to clipboard
fflib_QueryFactory().selectFieldSet() fails with when FieldSet queries namespaced fields
I have a valid FieldSet that contains field of a managed Custom Object and some fields of a related objects
When I run this code in unmanaged namespace-less org
new fflib_QueryFactory(CustomObject__c.SObjectType)
.selectFieldSet(SObjectType.CustomObject__c.Fieldsets.MyFieldSet)
it perfectly works. When try the same in a managed org with namespace (make Cusom Object and the related Object part of this namespace) it fails with:
caused by: UP2GO_2F.fflib_QueryFactory.InvalidFieldException: Invalid field 'NAMESPACE__Field__c' for object 'NAMESPACE__CustomObject__c'
Class.NAMESPACE.fflib_QueryFactory.getFieldToken: line 95, column 1
Class.NAMESPACE.fflib_QueryFactory.selectFieldSet: line 276, column 1
Class.NAMESPACE.fflib_QueryFactory.selectFieldSet: line 262, column 1
Class.NAMESPACE.MasterPartSelectCtrlExt: line 94, column 1
@capeterson one for you? :+1:
Looks like it. I'll dig in shortly and see what can be done. On Aug 13, 2014 3:52 AM, "Andrew Fawcett" [email protected] wrote:
@capeterson https://github.com/capeterson one for you? [image: :+1:]
— Reply to this email directly or view it on GitHub https://github.com/financialforcedev/fflib-apex-common/issues/24#issuecomment-52033985 .
This might be connected to this Know Issue: https://success.salesforce.com/issues_view?id=a1p30000000SzK3AAK
@afawcett from looking at the class I think the root cause lies out side this class and instead in fflib_SObjectDescribe
@afawcett and @capeterson I hope I could fix this in pull request https://github.com/financialforcedev/fflib-apex-common/pull/25
Taking a look at this I have to ask if it actually fixed the issue for you? The fflib_SObjectDescribe.getField method delegates to the FieldsMap.get implementation which already lower-cases the input at that level. Although of course it's late and I may be missing some detail.
It's true that you store the field names in lower case in your Describe cache class, but you definitly do not lower case the field names you extract from a Fieldsets FieldSetMember.
FieldSetMember myField = ...
String stillMixedCase = myField.getFieldPath();
...getFieldToken(stillMixedCase);
Schema.DescribeSObjectResult describe = getDescribe();
Schema.SObjectField field = describe.getField(stillMixedCase);
Hi @up2go-rsoesemann is there still an issue here? @capeterson whats your thoughts?
If it's still an issue certainly needs to be fixed, I also need to reconcile the private and public versions, I think we've had a few bug fixes on the internal version I need to migrate to this repo.