1

Has anyone played with the new beta for being able to delete fields from a managed package?

The Issue I am having is:

  1. Field has been delete in managed package
  2. Package installed in target org
  3. I can access the field via the Dev console when logged into the target org as a user of that org: [Select xxx__Deleted_Field__c From xxx_Object__c]; just fine
  4. However when putting the EXACT same query in an apex class (not part of package) I get the "Invalid Field" error
  5. In addition, when I get the values from the Dev Console they debug fine but when I pass the object list to the class the debug now shows the fields not present

Any ideas why I can do something in the dev console but NOT in an apex class with the exact same code?

Dev Console Output

14:15:52.119 (119531093)|EXECUTION_STARTED
14:15:52.119 (119540405)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
14:15:52.120 (120738649)|SOQL_EXECUTE_BEGIN|[1]|Aggregations:1|select xxx__Assigned_Attorney__c, xxx__Additional_Attorneys__c, xxx__Assigned_Paralegal__c, (select xxx__Case__c, xxx__Staff_Member__r.Name, xxx__Role__c from xxx__Staff_Members__r) from xxx__Case__c where ID = 'a02G000000I8zv6'
14:15:52.139 (139711318)|SOQL_EXECUTE_END|[1]|Rows:1
14:15:52.140 (140089765)|USER_DEBUG|[3]|ERROR|(xxx__Case__c:{xxx__Additional_Attorneys__c=B T, Id=a02G000000I8zv6IAB, xxx__Assigned_Paralegal__c=C M})
14:15:52.159 (159001989)|METHOD_ENTRY|[1]|01pG0000003q6kO|migrateToStaffMembers.migrateToStaffMembers()
14:15:52.159 (159268235)|USER_DEBUG|[4]|ERROR|(xxx__Case__c:{Id=a02G000000I8zv6IAB})
14:15:52.161 (161819069)|USER_DEBUG|[162]|ERROR|Invalid field xxx__Paralegal__c for xxx__Case__c

Line 1: Debug of xxx__Case__c object List - Passed this List to the method - migrateToStaffMembers Line 4: Debug of the value of the passed in list in Line 1 Line 162: error

All of this was from the dev console, the class is NOT part of the package, it was written to see if we could migrate data from a lookup filed to a new object in the package.

  • 1
    Are they using the same version of the package? – BritishBoyinDC Sep 18 '14 at 17:01
  • The class is outside of the package. So in the target org, the dev console (logged in as user of target org) can access but a class (not part of the package) cannot – Eric Sep 18 '14 at 17:28
0

I was just playing with this feature yesterday. I did notice that after upgrading an org to the new version of my package (one with the fields deleted), the target org still had those fields in the org. They show up in the field list of the target object, however, they no longer have the little icon next to them that suggests they are part of the managed package. I believe this is done so that the subscriber can continue to use the field if they want or can export data from that field.

So, this is a bit of speculation, but perhaps the subscriber can still access those fields via the Developer Console, but to do so must still append the namespace prefix. But from the perspective of your app, the fields are considered either (a) deprecated? or (b) not part of your package's namespace?

Hope that helps.

  • I am not trying to access it from my app. As per my explanation the apex class is not a part of the package, it is in the target org. It is NOT namespaced. The Dev console is NOT running under the managed package. The Dev Console CAN access the field, but the apex Class CANNOT. Again Class is NOT part of the package, it is part of the target org. – Eric Sep 18 '14 at 18:14
  • Yes - but an apex class acts against a particular version of a package (see version tab) - so if it is referencing the most recent version of the package, those fields don't exist anymore in the package - but per the answer above, they do still exist in the org so the customer can save the data...so they would still be available in the dev console to query – BritishBoyinDC Sep 18 '14 at 18:23
4

An Apex Class does care about the version of the managed package - your code in the target Org can access different versions of any managed package by selecting the Package Version in the versions tab - so your class is probably accessing the new version of the package, which doesn't have the fields - but if the fields are still there in the target Org, then the dev console can see them - but the versioning is probably preventing the Apex class from accessing those fields in the package since they have been removed from the package, but not necessarily from the target Org. Package Versions

  • Ugh, the little thing. Ok, So is there a way programmatically to set the version for the class? I am going to look now. This must be the issue – Eric Sep 18 '14 at 19:03
  • Ok, Marking this one answered as I know why, posting a new question related to how.... – Eric Sep 18 '14 at 19:14
-1

I fixed this issue, by setting the classes Version Settings for the fields package, to a lower number, where the field was still existing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.