System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Task.Whatid
Most of the times we miss to add that field in selection and try to use but in our case its in selection still got that error.
Real Time Scenario : We faced this issue when new task field is added on the existing code and Trying to deploy to higher environment.& It took a while to figure out the root cause because same code was working earlier and above mentioned "WhatId" is coming in the SOQL query as well.
Root Cause : Adding the new activity field permission in admin profile which is causing issue, By default activity fields will have access to admin profile not required to mention explicitly and by mentioning explicitly for the new added filed it overridden and has access to only new field and other fields are getting above mentioned error.
Ex: In admin profile under field permissions added readable & edit permission.
<field>Activity.NewCustomField__c</field>
Fix :
- Remove the entries from the package profile file
- Change the activity to task Ex: <field>Task.NewCustomField__c</field>
Troubleshoot & Investigation Steps :
1. Issue occurred during the deployment to higher environment and Deployment happens though api user as per our configuration & It's profile is admin profile .
2. Verify the admin profile changes in the PR & Try to revert and validate the PR.
3. If PR validation success then good to understand the root cause ,If still issue occurs validate the changes incrementally to identify the issue.
No comments:
Post a Comment