Another Salesforce blog!!!

Salesforce, Apex

Error, “List has no rows for assignment to SObject”


It would be safer to do the following:

Player__c[] players = [SELECT Id from Player__c where Name = :username];
if (players.size() > 0)
p = players[0].Id;

Leave a Reply

Your email address will not be published. Required fields are marked *

*