You need to sign in to do that
Don't have an account?
Tall 642
System.QueryException: List has no rows for assignment to SObject on Milestone Autocomplete Code
I have implemented some code from developerforce to the auto-clomplete milestones, and in doing so I am getting the error in the Subject line. I'm not sure what is going wrong, here are the segments where tests are indicating being broken:
Entitlement entl = [select id from Entitlement limit 1]; String entlId; if (entl != null) entlId = entl.Id;
here is the link to the code that I am using. Any help would be appreciated:
http://wiki.developerforce.com/index.php/Case_Milestones_Utilities_Class
Modify line number 5 as:
List<CaseMilestone> cmsToUpdate = new List<CaseMilestone>();
cmsToUpdate = [select Id, completionDate from CaseMilestone cm where caseId in :caseIds and cm.MilestoneType.Name=:milestoneName and completionDate = null limit 1];
In short create instance of list first and then query.
Regards,
Lakshman
All Answers
Modify line number 5 as:
List<CaseMilestone> cmsToUpdate = new List<CaseMilestone>();
cmsToUpdate = [select Id, completionDate from CaseMilestone cm where caseId in :caseIds and cm.MilestoneType.Name=:milestoneName and completionDate = null limit 1];
In short create instance of list first and then query.
Regards,
Lakshman
A SOQL Select statement returns a List of SObjects. Salesforce created this code shortcut to assign the result List to a single SObject. However it gives an error if the list is empty.
Assigning the Select results to a List of SObject does not give an error if the list is empty.
Worked like a charm. Thank you. :smileyhappy: