You need to sign in to do that
Don't have an account?
Gabe Rothman 8
Help: getting "list has no rows for assignment" error, but debug log says otherwise...
Hey all, I have two custom objects: Feature__c and Feature_Request__c. Feature__c is the parent object in a master-detail relationship with Feature_Request__c. When a Feature__c's status is update to "Accepted" I need to update two lookups on all of the Feature__c's child Feature_Request__c's. First I need to clear out the the Proposed_Feature__c lookup and then I need to populate the Feature__c master-detail with the id of the record that was previously populated in the Proposed_Feature__c lookup. As far as I can tell my code should work, but I keep getting a "list has no rows for assignment" error despite the debug log saying that all of my lists are populated. I've posted the code and the debug log below. Any help would be greatly appreciated.
Trigger:
Helper Class:
Debug Statements:
Link to Complete Debug Log: https://docs.google.com/document/d/1S7n2LWqWfG7NU97sJ9E1ZAooIwDdiHiTpgEyWShzHXg/edit?usp=sharing
Trigger:
trigger Feature on Feature__c (after update) { if(trigger.isAfter && trigger.isUpdate){ for(Feature__c f : trigger.new){ if(f.Status__c == 'Accepted'){ updateFrsFromApprovedFeature.updateFeatureRequests(updateFrsFromApprovedFeature.filterFeature(trigger.oldmap,trigger.new)); } } } }
Helper Class:
public class updateFrsFromApprovedFeature { public static list<Feature__c> filterFeature(map<id, Feature__c> oldMap, list<Feature__c> newList) { list<Feature__c> temp=new list<Feature__c>(); for (Feature__c newFeat : newList) { if (oldMap.get(newFeat.id).Status__c != newFeat.Status__c && newFeat.Status__c == 'Accepted'){ temp.add(newFeat); } } return temp; } public static void updateFeatureRequests(list<Feature__c> frUpdateList) { Feature__c featproxy = [SELECT Id, Status__c FROM Feature__c WHERE Id in: frUpdateList]; system.debug(featproxy); List<Feature_Request__c> frs = [SELECT Feature__c, Proposed_Feature__c FROM Feature_Request__c WHERE Proposed_Feature__c =: featproxy.id]; system.debug(frs); List<Feature_Request__c> updateFrs = new list<Feature_Request__c>(); for(Feature_Request__c updatefr : frs){ updatefr.Feature__c = featproxy.Id; updatefr.Proposed_Feature__c = null; updateFrs.add(updatefr); } system.debug(updateFrs); If(updateFrs.size()>0){ update updateFrs; } } }
Debug Statements:
09:10:30:109 USER_DEBUG [17]|DEBUG|Feature__c:{Id=a11i000000CcIJYAA3} 09:10:30:114 USER_DEBUG [21]|DEBUG|(Feature_Request__c:{Feature__c=a11i000000CdxuPAAR, Proposed_Feature__c=a11i000000CcIJYAA3, Id=a10e0000002L7K4AAK}, Feature_Request__c:{Feature__c=a11i000000CdxuPAAR, Proposed_Feature__c=a11i000000CcIJYAA3, Id=a10e0000002L7K9AAK}) 09:10:30:115 USER_DEBUG [28]|DEBUG|(Feature_Request__c:{Feature__c=a11i000000CcIJYAA3, Proposed_Feature__c=null, Id=a10e0000002L7K4AAK}, Feature_Request__c:{Feature__c=a11i000000CcIJYAA3, Proposed_Feature__c=null, Id=a10e0000002L7K9AAK})
Link to Complete Debug Log: https://docs.google.com/document/d/1S7n2LWqWfG7NU97sJ9E1ZAooIwDdiHiTpgEyWShzHXg/edit?usp=sharing
Thanks
Amit Chaudhary
All Answers
This is odd to me because as you can see from my debug statement in line 17, featproxy does contain an Id.
Thanks
Amit Chaudhary