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
memtiger623memtiger623 

Why would outputPanel rendered = false render after a rerender.

I have a pageBlockTable with this code following as a column.  Because its for a search page and Ive got the option for both an SOQL and a SOSL query in the same page I had to modify the results returned.  I do not know how to including child relationships into activityhistories into an SOSL query so I wanted to block out the part asking for the activityhistory that I have included in the SOQL query.   I made an outputPanel that would render based on the type of query being run.  The SOSL query will display correctly on the first load, but if you add a parameter and try to rerender the page based on new criteria, I get "System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Contact.OpenActivities" as an error. I then proceeded to try to turn rendered = "false" to stop it from ever loading.  This did not change anything.  Why would the part in the outputPanel work the first time but fail after a rerender?  Is there a way I can change my code in order to allow two different queries that pull back different result sets?

 

<apex:column">

                <apex:facet name="header">

                     Recent Activity               

</apex:facet>             

<apex:outputPanel layout="none" rendered="false">                   

<div style="width: 400px; height: 50px;overflow:-moz-scrollbars-vertical;overflow-y:auto;">                       

<TABLE>                       

<apex:repeat value="{!contact.con.OpenActivities}" var="task">

                                <TR>

<TD>

<apex:outputField value="{!task.LastModifiedDate}" style="font-weight: bold;"/>

</TD>

<TD>

<apex:outputText value="{!task.ActivityType}"/>:&nbsp;<apex:outputText value="{!task.Subject}"/>

</TD>

</TR>

                               </apex:repeat>

                               <apex:repeat value="{!contact.con.ActivityHistories}" var="task">         

                       <TR>

<TD>

<apex:outputField value="{!task.LastModifiedDate}" style="font-weight: bold;"/>

</TD>

<TD>

<apex:outputText value="{!task.ActivityType}"/>:&nbsp;<apex:outputText value="{!task.Subject}"/>

</TD>

      </TR>

                            </apex:repeat> 

                      </TABLE>

</div>

</apex:outputPanel>

</apex:column>

 

 

Thank you for any help

bob_buzzardbob_buzzard

I can't think of any reason why this would happen.  I've used this in the past and can't remember hitting this type of issue.

 

Can you post the full page and controller?

memtiger623memtiger623

Alot of my code comes from the search tool on your blog.  Ive only been doing Salesforce stuff for 2 months now.  My code is kinda long so i'm cutting it down to the relevant parts.

 

Controller

 

 private String SOQLCONST = 'SELECT ID, AccountID, FirstName, LastName, Name, Active_Date__c, Type_of_Position_Desired__c, Interest__c, Comments__c, Apperance_and_Presentation__c, SOU__c,'+
                            ' What_do_they_want__c, Min_Salary__c, Current_Salary__c, Boxed_Salary__c, Min_Hourly_Rate__c, Current_Hourly_Rate__c, Boxed_Hourly_Rate__c,'+
                          ' (SELECT Subject,LastModifiedDate, ActivityType FROM ActivityHistories ORDER BY LastModifiedDate DESC), (SELECT Subject,LastModifiedDate, ActivityType FROM OpenActivities ORDER BY LastModifiedDate DESC) FROM Contact WHERE recordtypeid = \'012500000005GX9AAM\'';

// runs the actual query
  public void runQuery() {
    contacts = new List<cContact>();
    try {
      queryDebug = soql + ' order by ' + sortField + ' ' + sortDir + ' LIMIT 200';
      for (Contact c : Database.query(queryDebug))
        contacts.add(new cContact(c));
    } catch (Exception e) {
    ApexPages.addMessages(e);
    }
  }
 
 
  public void runSOSLQuery() {
   List<Contact> contactlist;
   contacts = new List<cContact>();
   
    try {
      queryDebug = soql + ' order by ' + sortField + ' ' + sortDir + ' LIMIT 200)';
      contactlist = (Search.query(queryDebug)).get(0);
      
      for (Contact c : contactlist)
        contacts.add(new cContact(c));
        
    } catch (Exception e) {
      ApexPages.addMessages(e);
    }
  }
  
  // runs the search with parameters passed via Javascript
  public void runSearch() {
 
   String soslSearch = Apexpages.currentPage().getParameters().get('soslSearch');
    String firstName = Apexpages.currentPage().getParameters().get('firstName');
    String lastName = Apexpages.currentPage().getParameters().get('lastName');
    String current = Apexpages.currentPage().getParameters().get('current');
    String Interest = Apexpages.currentPage().getParameters().get('interest');
    String interestsub = Apexpages.currentPage().getParameters().get('interestsub');
    String typeOfPosition = Apexpages.currentPage().getParameters().get('typeOfPosition');
    String local = Apexpages.currentPage().getParameters().get('local');
    String active = Apexpages.currentPage().getParameters().get('activeValue');
    String cert = Apexpages.currentPage().getParameters().get('certifications');
 
    if(soslSearch.equals(''))
      soql = SOQLCONST;
    else
      soql = 'FIND \''+soslSearch+'\' IN ALL FIELDS RETURNING Contact (ID, AccountID, FirstName, LastName, Name, Active_Date__c,'+ 
                    'Type_of_Position_Desired__c, Interest__c, Comments__c, Apperance_and_Presentation__c, SOU__c,'+
                    ' What_do_they_want__c, Min_Salary__c, Current_Salary__c, Boxed_Salary__c, Min_Hourly_Rate__c,'+
                    ' Current_Hourly_Rate__c, Boxed_Hourly_Rate__c '+
                    ' WHERE recordtypeid = \'012500000005GX9AAM\'';
 
    if (!firstName.equals(''))
      soql += ' and firstName LIKE \''+String.escapeSingleQuotes(firstName)+'%\'';
    if (!lastName.equals(''))
      soql += ' and lastName LIKE \''+String.escapeSingleQuotes(lastName)+'%\'';
    if(!current.equals(''))
      soql += ' and Current_Position_Type__c = \''+current+'\'';
    if (!interest.equals(''))
      soql += ' and interest__c = \''+interest+'\'';
    if (!interestsub.equals(''))
      soql += ' and interest_sub__c INCLUDES (\''+interestsub+'\')';
    if (typeOfPosition.equals('Contract Group'))
      soql += ' and Type_of_Position_Desired__c in ('+CONTRACTCONST+')';
    else if (typeOfPosition.equals('Contract to Hire Group'))
      soql += ' and Type_of_Position_Desired__c in ('+PERMCONST+')';  
    else if (typeOfPosition.equals('Permanent Group'))
      soql += ' and Type_of_Position_Desired__c in ('+CONTHIRECONST+')';      
    else if (!typeOfPosition.equals(''))
      //Not a grouping
      soql += ' and Type_of_Position_Desired__c = \''+typeOfPosition+'\'';
    if (!cert.equals(''))
      soql += ' and certifications__c = \''+cert+'\'';
    if (local.equals('Yes'))
      soql += ' and local__c = \'Yes\'';
    else if (local.equals('No'))
      soql += ' and local__c = \'No\'';
    else if (local.equals('Not No'))
      soql += ' and local__c != \'No\'';
    if (active.equals('Yes'))
      soql += ' and active_date__c != NULL';
    else if (active.equals('No'))
      soql += ' and active_date__c = NULL';
    // run the query again
    if(soslSearch.equals(''))
    {
      runQuery();
      queryType = 'soql';
    }
    else
    {
      runSOSLQuery();
      queryType = 'sosl';
    }
  }

 

memtiger623memtiger623

Page:

<apex:pageBlock mode="edit" id="results">
 
        <apex:pageBlockTable value="{!contacts}" var="contact">
            
            <apex:column style="{!IF(contact.con.Active_Date__c < TODAY() - 21, 'background-color:#FFCCCC', '')}">
                <apex:inputCheckbox value="{!contact.selected}">
                    <apex:actionSupport event="onclick" action="{!useSelectedContacts}" rerender="returnedblock"/>
                </apex:inputCheckbox>
            </apex:column>
 
            <apex:column style="{!IF(contact.con.Active_Date__c < TODAY() - 21, 'background-color:#FFCCCC', '')}">
                <apex:facet name="header">
                    <apex:commandLink value="Name" action="{!toggleSort}" rerender="results,debug" onComplete="tooltipMethod();">
                        <apex:param name="sortField" value="lastName" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <a href="/{!contact.con.ID}" rel="{!contact.con.ID}" class="qtiphover">{!contact.con.Name}</a>
            </apex:column>
            
            <apex:column style="{!IF(contact.con.Active_Date__c < TODAY() - 21, 'background-color:#FFCCCC', '')}">
                <apex:facet name="header">
                    <apex:commandLink value="Active Date" action="{!toggleSort}" rerender="results,debug" onComplete="tooltipMethod();">
                        <apex:param name="sortField" value="active_Date__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!contact.con.Active_Date__c}"/>
            </apex:column>
             
            <apex:column style="{!IF(contact.con.Active_Date__c < TODAY() - 21, 'background-color:#FFCCCC', '')}">
                <apex:facet name="header">
                    <apex:commandLink value="Interest" action="{!toggleSort}" rerender="results,debug" onComplete="tooltipMethod();">
                        <apex:param name="sortField" value="Interest__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!contact.con.Interest__c}"/>
            </apex:column>
 
            <apex:column style="{!IF(contact.con.Active_Date__c < TODAY() - 21, 'background-color:#FFCCCC', '')}">
                <apex:facet name="header">
                    <apex:commandLink value="A/P" action="{!toggleSort}" rerender="results,debug" onComplete="tooltipMethod();">
                        <apex:param name="sortField" value="Apperance_and_Presentation__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputText value="{!LEFT(contact.con.Apperance_and_Presentation__c,1)}"/>
            </apex:column>
            
            <!-- <apex:column style="{!IF(contact.con.Active_Date__c < TODAY() - 21, 'background-color:#FFCCCC', '')}">
                <apex:facet name="header">
                    <apex:commandLink value="SOU" action="{!toggleSort}" rerender="results,debug" onComplete="tooltipMethod();">
                        <apex:param name="sortField" value="SOU__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!contact.con.SOU__c}"/>
            </apex:column> -->
 
            <apex:column style="{!IF(contact.con.Active_Date__c < TODAY() - 21, 'background-color:#FFCCCC', '')}; width: 400px;">
                <apex:facet name="header">  
                    Current Job Description
                </apex:facet>
                <div style="width: 400px;height: 50px;overflow:-moz-scrollbars-vertical;overflow-y:auto;">
                        <apex:outputField value="{!contact.con.Comments__c}"/>
                </div>
            </apex:column>
 
            <!-- <apex:column style="{!IF(contact.con.Active_Date__c < TODAY() - 21, 'background-color:#FFCCCC', '')}">
                <apex:facet name="header">
                    <apex:commandLink value="Position Desired" action="{!toggleSort}" rerender="results,debug" onComplete="tooltipMethod();">
                        <apex:param name="sortField" value="Type_Of_Position_Desired__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!contact.con.Type_of_Position_Desired__c}"/>
            </apex:column> -->
  
            <apex:column style="{!IF(contact.con.Active_Date__c < TODAY() - 21, 'background-color:#FFCCCC', '')}">
                <apex:facet name="header">
                    Current Pay
                </apex:facet>
                <apex:outputField value="{!contact.con.Current_Salary__c}" rendered="{!IF(contact.con.Current_Salary__c == null, false, true)}"/>
                <apex:outputField value="{!contact.con.Current_Hourly_Rate__c}" rendered="{!IF(contact.con.Current_Hourly_Rate__c == null, false, true)}"/>
            </apex:column>
     
            <apex:column style="{!IF(contact.con.Active_Date__c < TODAY() - 21, 'background-color:#FFCCCC', '')}">
                <apex:facet name="header">
                    Salary - Hourly
                </apex:facet>
                <apex:outputText value="?" rendered="{!IF(ISNULL(contact.con.Min_Salary__c), true, false)}" /> 
                <apex:outputField value="{!contact.con.Min_Salary__c}"/>
                <apex:outputText value=" / " />
                <apex:outputText value="?" rendered="{!IF(ISNULL(contact.con.Boxed_Salary__c), true, false)}" /> 
                <apex:outputField value="{!contact.con.Boxed_Salary__c}" />
                <BR/>
                <apex:outputText value="?" rendered="{!IF(ISNULL(contact.con.Min_Hourly_Rate__c), true, false)}" />
                <apex:outputField value="{!contact.con.Min_Hourly_Rate__c}"/>
                <apex:outputText value=" / " />
                <apex:outputText value="?" rendered="{!IF(ISNULL(contact.con.Boxed_Hourly_Rate__c), true, false)}" /> 
                <apex:outputField value="{!contact.con.Boxed_Hourly_Rate__c}" />
            </apex:column>
        
            <apex:column style="{!IF(contact.con.Active_Date__c < TODAY() - 21, 'background-color:#FFCCCC', '')}">
                <apex:facet name="header">
                    Account
                </apex:facet>
                <apex:outputField value="{!contact.con.AccountID}"/>
            </apex:column>
      
            <apex:column style="{!IF(contact.con.Active_Date__c < TODAY() - 21, 'background-color:#FFCCCC', '')}; width: 400px;">
                <apex:facet name="header">  
                    Recent Activity
                </apex:facet>
                <apex:outputPanel layout="none" rendered="{!IF(queryType == 'soql', true, false)}">
                    <div style="width: 400px; height: 50px;overflow:-moz-scrollbars-vertical;overflow-y:auto;">
                        <TABLE>
                        	<apex:repeat value="{!contact.con.OpenActivities}" var="task">
                                <TR><TD><apex:outputField value="{!task.LastModifiedDate}" style="font-weight: bold;"/></TD><TD><apex:outputText value="{!task.ActivityType}"/>:&nbsp;<apex:outputText value="{!task.Subject}"/></TD></TR>
                            </apex:repeat>
                            <apex:repeat value="{!contact.con.ActivityHistories}" var="task">
                                <TR><TD><apex:outputField value="{!task.LastModifiedDate}" style="font-weight: bold;"/></TD><TD><apex:outputText value="{!task.ActivityType}"/>:&nbsp;<apex:outputText value="{!task.Subject}"/></TD></TR>
                            </apex:repeat>
                        </TABLE>
                    </div> 
                </apex:outputPanel>
            </apex:column>
        
        </apex:pageBlockTable>
 
    </apex:pageBlock>