I am trying to update a checkbox field on a custom object when a checkbox is checked in a list of these objects. The error is saying that no rows have been returned by my query. I am getting the object based on the ID or Name of the record clicked. My problem is I don't know which to use. I have the Name field set as an autonumber.
<apex:pageBlockTable value="{!allNotes}" var="note" id="list">
<apex:column value="{!note.Created__c}"/>
<apex:column value="{!note.Body__c}"/>
<apex:column>
<apex:inputCheckbox value="{!note.DidyaGetterDone__c}">
<apex:actionSupport event="onclick" reRender="list" action="{!checkNote}">
<apex:param assignTo="{!noteIdValue}" value="{!note.Name}"/>
</apex:actionSupport>
</apex:inputCheckbox>
</apex:column>
</apex:pageBlockTable>
Controller:
public with sharing class StudyPageController {
public Notes__c note{get;set;}
public List<Notes__c> allNotes{get;set;}
public String noteIdValue{get;set;}
public StudyPageController(){
questionList = [Select id,body__c,answer__c,Name,Type__c,Explanation__c,Category__c,A__c,B__c,C__c,D__c,E__c,pic1__c,pic2__c,pic3__c,pic4__c,pic5__c From Question__c];
allNotes = [Select Name,Created__c,body__c,DidyaGetterDone__c From Notes__c];
note = new Notes__c();
}
public void checkNote(){
Notes__c updateNote = [Select ID,Name,DidyaGetterDone__c From Notes__c Where Name = :noteIdValue];
updateNote.DidyaGetterDone__c = !updateNote.DidyaGetterDone__c;
update updateNote;
}
}
This is the error:
List has no rows for assignment to SObject Error is in expression '{!checkNote}' in page notespage: Class.StudyPageController.checkNote: line 67, column 1