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
JNicJNic 

Bug: ActionFunction breaks inlineEdit on apex:detail

Hey all,

 

I'm wondering if someone knows a workaround for a bug I encountered.

 

It seems that apex details inlineEdit function breaks when you add an actionFunction to the page.

 

In this example:

 

 

<apex:page standardController="bltn__c" extensions="bulletinController">

    <apex:form >
        <!-- The function that checks the users "awareness status" of the bulletin -->
        apex:actionFunction action="{!processAwareness}" reRender="none" name="jsProcessAwareness" />
        <apex:detail inlineEdit="true" relatedList="true" relatedListHover="true" showChatter="true" subject="{!$CurrentPage.parameters.id}"/>
    </apex:form>

    <script>
        window.onload = jsProcessAwareness();
    
    </script>

</apex:page>

 

public with sharing class bulletinController {
  
    public bulletinController(ApexPAges.StandardController controller) {
        
    }
    
    public void processAwareness() {
        usrBltn__c[] u = [SELECT id, awareness__c FROM usrBltn__c WHERE bulletin__c = :ApexPages.currentPage().getParameters().get('id') AND user__c = :userInfo.getUserId() AND awareness__c = 'Informed' LIMIT 1];
        if (!u.isEmpty()) {
            u[0].awareness__c = 'Viewed';
            update u;
        }
    }
}

 

I cannot inline edit the detail record.

I CAN when I remove the action function from the page.

 

I need a workaround please.

 

Thanks,

JNH

 

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

It may be that you have inadvertently taken out an onload handler function that the inline editing relies on.

 

Rather than specifying the onload handler as jsProcessAwareness(), try adding this to the existing handlers, using something like the following:

 

 

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(jsProcessAwareness);

 

 

 

All Answers

bob_buzzardbob_buzzard

It may be that you have inadvertently taken out an onload handler function that the inline editing relies on.

 

Rather than specifying the onload handler as jsProcessAwareness(), try adding this to the existing handlers, using something like the following:

 

 

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(jsProcessAwareness);

 

 

 

This was selected as the best answer
Pradeep_NavatarPradeep_Navatar

There is some error in VF code so that code is not working fine.

 

              <apex:page standardController="bltn__c" extensions="bulletinController">

              <apex:form >

              <!-- The function that checks the users "awareness status" of the bulletin -->

              <apex:actionFunction action="{!processAwareness}" reRender="none" />

 

               // Error in this line You did not give proper syntax actionfunction.

 

               <apex:detail inlineEdit="true" relatedList="true" relatedListHover="true" showChatter="true" subject="
               {!$CurrentPage.parameters.id}"/>

               </apex:form>

               <script>

                     window.onload = jsProcessAwareness();

               </script>

               </apex:page>

JNicJNic

That did it Bob!

 

Thanks.