You need to sign in to do that
Don't have an account?
Nick Keehan
List has no rows, simple IF statement not working if case not found
Hopefully quick question.
Keep getting List has no rows error. Tried a couple of suggestions online like size however my Mycase.Referral_Status__c errors with Method not found.
Hopefully easy enough to fihure out the issue. The below is under my Save() function. (objacc is referenced on the vf page)
Keep getting List has no rows error. Tried a couple of suggestions online like size however my Mycase.Referral_Status__c errors with Method not found.
Hopefully easy enough to fihure out the issue. The below is under my Save() function. (objacc is referenced on the vf page)
Case MyCase = [Select Id, CaseNumber from Case where CaseNumber = :objacc.Case_Reference__c]; if(MyCase != null){ MyCase.Referral_Status__c = 'Success'; MyCase.Referral_Type__c = 'New'; MyCase.VF_Account_Number_C3__c = objacc.Customer_Row_ID__c; update MyCase; } else { return null; }
Figured this one out myself.
Had the query occuring before the IF Statement. That was returning 0 results and erroring.
instead swapped the query and IF around.
All Answers
Same Error unfortunatly.
System.QueryException: List has no rows for assignment to SObject
Error is in expression '{!save}' in component <apex:commandButton> in page fibresimplex: Class.AccExtension3.Save: line 124, column 1
Line 124 is the MyCase Query.
My code and your works fine if there is a case number entered, however errors when no case is found.
Any suggestions?
Nick
Changes the Case Number checks to Subject which is writeable, no luck.
Same list has no rows error. Ill keep looking online.
thanks
Figured this one out myself.
Had the query occuring before the IF Statement. That was returning 0 results and erroring.
instead swapped the query and IF around.