I have a visualforce page with a custom controller. The custom controller fills in some information in the header of my datatable:
timesheetOwner = [select service_staff__r.name from service_documentation__c
where service_staff__c = 'a23M0000001A6FjIAK' limit 1].service_staff__r.name;
In the anon window, the following code also works:
timesheetOwner = [select service_staff__r.name from service_documentation__c
where service_staff__c = 'a23M0000001A6FjIAK' limit 1].service_staff__r.name;
system.debug('timesheetowner = '+timesheetowner);
This works fine on my VF page, but when I try to test and deploy to production, I get the error:
"List has no rows for assignment to Sobject"
In placing various debug lines in the code, sure enough, the variable shows as null.... however, when I take the SOQL select and place it in the query editor, it works... Very confusing...
Originally, the implicit service_staff__c
filter used a variable and gave the same error. I then tried the select with the literal content and got the same error.
So in a nutshell:
- I have a line of code that for all practical purposes... works
- The line doesn't work when testing
- The code won't deploy for the same reason
Any ideas?
Thanks, Marty
Service_documentation__c
in your code?