enter image description here

Im planning to update each row using actionSupport event = "onchange". I'm trying to get the ID of the row but it is NULL.

Or Is there any way It can be updated as a list without using the recordsetVar.

Here is my visualforce page:

    <apex:form >
        <apex:pageBlock >            
                <apex:pageBlockSection >                
                    <apex:pageBlockTable value="{!ORRQualQuestions}" var="ques" html-cid="usersAppTable"> 
                        <apex:column value="{!ques.Sequence__c}" headerValue="Sequence" headerClass="TableTitle"/>
                        <apex:column value="{!ques.Department__c}" headerValue="Department" headerClass="TableTitle"/>
                        <apex:column value="{!ques.Type__c}" headerValue="Type" headerClass="TableTitle"/>
                        <apex:column value="{!ques.Questionnaires__c}" headerValue="Questionnaires" headerClass="TableTitle"/> 
                        <apex:column >
                            <apex:param name="id" value="{!ques.Id}" assignTo="{!tobeEdited}"></apex:param>
                            <apex:outputText value="{!ques.Id}"></apex:outputText>
                        <apex:column headerValue="Status">
                            <apex:inputField value="{!ques.Status__c}"></apex:inputField>
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>



Apex Class:

public class ORRQual {

    private final List<ORRQual__c> questions;

    public ORRQual__c items {get;set;}
    public ORRQual__c tobeEdited{get;set;}

    public ORRQual(ApexPages.StandardController controller){  
      this.items = (ORRQual__c)controller.getRecord();
      questions = [SELECT Department__c,Id,Questionnaires__c,Sequence__c,Status__c,Type__c FROM ORRQual__c where Type__c = 'Country' order by Sequence__c ];


    public List<ORRQual__c> getORRQualQuestions(){
        return questions;

    public PageReference save(){
        PageReference pr = new PageReference('/apex/ORRQual');
                update answeredQuestions;               

        }catch(Exception e){

       return pr;

Kindly help me regarding on my issues. Thanks a lot Salesforce community.


If you just do a post-back, the status should be updated so you can call update on the whole list to update the status, but if you want to limit it to the record that was actually updated, you need to change your markup a bit (I've taken out the other columns for clarity):

<apex:pageBlockTable value="{!ORRQualQuestions}" var="ques" html-cid="usersAppTable"> 
    <apex:column headerValue="Status">
        <apex:inputField value="{!ques.Status__c}">
            <apex:actionSupport event="onchange" action="{!updateQuestion}">
                <apex:param name="toBeEdited" value="{!ques.ID}" assignTo="{!toBeEdited}" />

public ID toBeEdited {get;set;}

public void updateQuestion()
    for(ORRQual__c qual : ORRQualQuestions)
        if (qual.ID == toBeEdited)
            update qual;
| improve this answer | |
  • DML in for loop is not a good practice – Santanu Boral Aug 13 '17 at 15:41
  • @SantanuBoral It's only possible for it to execute once. – IllusiveBrian Aug 13 '17 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.