function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JonWuJonWu 

Need help: inline editing in pageBlockTable only saves 1 record

I've run across what seems to be a bug. I've contact support but they closed my case. Hopefully I can get that re-opened, but until then maybe somebody here can help file an official bug and I hope this can help somebody else. I've been tearing my hair out over this!

 

This has happened on a few objects so it's not object specific. However in this example I have an object called CustomerSpecialInstruction which has a Master-Detail field to account.

 

BUG OVERVIEW

 

When using <apex:inlineEditSupport/> within a pageBlockTable which outputs columns and headers automatically using <apex:column value="{!someField}"/> just like the example in the pageBlockTable documentation, only the last row of the table updates when the page is saved. The inline editing quick start documentation also lists taht the inlineEditSupport tage can be a descendant of pageBlockTable so according to the documentation this should work.

 

These screenshots show the issue:

 

BEFORE SAVING

 

Here, I've edited all 3 rows. When clicking save you'd expect that all 3 rows are updated to the values you see here.

To reproduce, try saving multiple rows of data in an inline editable pageBlockTable which doesn't use apex:outputField

 

AFTER SAVING

 

You see that updates are only applied to the last row for the column that didn't use an outputField to display the value (Archived). The Name column was updated for all records because the value was outputted using outputField instead of apex:column. To see where I made this workaround, see where I have a comment saying DEBUG TESTING in my VisualForce code below.

 

Perhaps there's some internal ID conflict with the auto generated code that makes inline editing work.

 

Saving does not work\

 

DETAILS / CODE

 

I've made an extension to Account to create a getter to query any CustomerSpecialInstruction__c objects where Account__c == Account.Id as follows:

 

global without sharing class CustomerSpecialInstructionsDebug {
	
	private Account customer;
	private CustomerSpecialInstruction__c[] customerSpecialInstructions; 
	
	public CustomerSpecialInstructionsDebug(ApexPages.StandardController stdController) {
		this.customer = (Account) stdController.getRecord();
	}
	
	public PageReference saveAll() {
		update customerSpecialInstructions;
		return null;
	}
	
	public CustomerSpecialInstruction__c[] getCustomerSpecialInstructions() {
		if (customerSpecialInstructions == null) {
			customerSpecialInstructions = [ SELECT Name, Description__c, Archived__c
				FROM CustomerSpecialInstruction__c
				WHERE Account__c = :customer.Id ];
		}
		return customerSpecialInstructions;
	}
}

 

Then I have a page with a pageBlockTable with inlineEditing enabled:

 

<apex:page standardController="Account" extensions="CustomerSpecialInstructionsDebug" showHeader="false" sidebar="false">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton action="{!saveAll}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Customer Special Instructions" columns="1">
            	<apex:pageBlockTable value="{!customerSpecialInstructions}" var="instruction">
            		<apex:inlineEditSupport />
            		<apex:column width="40">
            			<apex:outputLink value="{!URLFOR($Action.CustomerSpecialInstruction__c.View, instruction)}">View</apex:outputLink>
            		</apex:column>
            		<apex:column value="{!instruction.Archived__c}"/>
            		<!-- DEBUG TESTING: Removed inline edit column and replaced with an inputField and everything works as expected! -->
            		<!-- <apex:column value="{!instruction.Name}"/> -->
            		<apex:column >
            			 <apex:outputField value="{!instruction.Name}"/>  
            		</apex:column>
            	</apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

I should be able to use this format for every column but I've discovered that when I do so, only 1 record saves: <apex:column value="{!instruction.Archived__c}"/> 

 

While writing up this simplified test case, I realized that if I explcitly define outputField here with inline editing (see instruction.Name vs the commented out version above it), everything works fine!

 

How can I get this bug fixed? Am I doing something wrong?

 

Thanks!

Best Answer chosen by JonWu
AJAY KRISHNA RAJAY KRISHNA R
Hi,

I am also new to Salesforce and I encountered with the same error. Consider writing the <apex:inlineEditSupport /> inside the <apex:column > and inside <apex:outputField>.
Example :
 <apex:column >
                  <apex:outputField value="{!instruction.Name}">
                    <apex:inlineEditSupport />
                  </apex:outputField >
  </apex:column>
and do give other attributes required for <apex:inlineEditSupport />.

Thank you..

All Answers

AJAY KRISHNA RAJAY KRISHNA R
Hi,

I am also new to Salesforce and I encountered with the same error. Consider writing the <apex:inlineEditSupport /> inside the <apex:column > and inside <apex:outputField>.
Example :
 <apex:column >
                  <apex:outputField value="{!instruction.Name}">
                    <apex:inlineEditSupport />
                  </apex:outputField >
  </apex:column>
and do give other attributes required for <apex:inlineEditSupport />.

Thank you..
This was selected as the best answer
JonWuJonWu
Hi Ajay,

Thanks for sharing.

To verify, you had the same issue as me, but you were able to fix it by moving the  <apex:inlineEditSupport /> tag as you've done above?

If so, I'll mark that as the answer as the answer to help others, but we're moving most of our development to custom JavaScript and away from Visualforce.
AJAY KRISHNA RAJAY KRISHNA R
Hi JonWu,

Yes, I too had the same issue and was able to fix it by modifying the code as above.

Thank you