3

I have an issue with querying a field from an object in my managed package. The managed package has been released and therefore the components mentioned are assumed to be permanent. I am trying to get a field value depending on a field mentioned in custom settings. For instance: I am trying to get the local custom field Local_Status__c. However, I have a managed field called NAMESPACE__Local_Status__c.

It seems that no matter how I go about querying in my managed package, the namespace is somehow appended to the query. I can use dynamic or 'static' queries without success.

Is there any way to get the data from that local field without having to change the local field's name? If it helps, the NAMESPACE__Local_Status__c field can be removed (if I can somehow remove released managed package components).

Any work arounds would be greatly appreciated.

2 Answers 2

3

You can delete the managed custom field, but be aware that doing so will prohibit you from ever being able to use that field name on that object in your managed package. Forever. It's a pretty brutal limitation, but if you're desperate, you can do it.

There's no way to access a local field that has the same name as the managed package field name on the same object. The system intentionally does this to make sure that your code doesn't accidentally compile on to a field that a subscriber has added after installation.

Deleting the field is probably your best option if you need to access that local field and you don't want to rename it.

1
  • Unfortunately it seems that I meet every qualification to NOT be able to delete or change any of my components. Thank you for the answer though, I will just have to think of a work around. Commented Oct 14, 2016 at 2:13
0

This is a frustrating gap given that generally the namespacing is effective in avoiding name clashes. I assume it is a consequence of the namespace defaulting when code within a managed package queries rather than a deliberate design choice.

If you only need to read the local field's value, a work-around is to add a formula field called e.g. Local_Status_Copy__c that replicates the value in Local_Status__c and configure Local_Status_Copy__c in your managed package custom settings.

PS

To clarify, the Local_Status_Copy__c would be created in the org not in the managed package. Then that could be accessed in the managed package because its name isn't shadowed by a field in the managed package.

2
  • Even the formula field seems to append the namespace. Error: Field NAMESPACE__Local_Status__c is a picklist field. Commented Oct 14, 2016 at 2:05
  • @KonnorMcDowell Sorry I wasn't clear - see the PS.
    – Keith C
    Commented Oct 14, 2016 at 8:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .