+ Start a Discussion
gomennasai123@n.orggomennasai123@n.org 

Pageblock Edit Mode does not update subquery fields in My visualforce page

Hi All;

 

I have Pageblock mode = edit in my VF page

I can only update the values from the parent SOQL query but no values from the subquery although I can display both values.

 

Below is my code and a screen shot. ( I added the basic lines to explain further)

 

 <apex:PageBlock mode="edit" id="block">

 

<apex:datatable value="{!searchResults}"  var="r" columns="10">
    
<!--   <apex:column headervalue="FirstName" style="width:200px"/> <apex:column headervalue="LastName" style="width:200px" /><apex:column headervalue="Time" style="width:200px"/>-->
   
   <apex:column >
  <apex:inputField value="{!r.Name}"/>&nbsp;&nbsp;
  </apex:column>
    <apex:column >
  <apex:inputField value="{!r.First_Name__c}"/>
  </apex:column>


 
 
         <apex:datatable value="{!r.Referral_Appointments__r}" var="a" >
            
       
    
    <apex:column >
      
           <apex:inputField value="{!a.Partner_Service_Provider__c}"/> <- does not update
           
    </apex:column>
    
    

 

My query from the controller:


 public list<new_referral_client__c> searchResults {get; set;}

public list<Referral_Appointment__c> ReferralApp1 {get; set;}

 

 

public PageReference search() {
 
  if (searchText != null && searchtext.length() > 0)
     {
    string selectstatement = 'select id,(select a.id, a.Appointment_date__c,a.timepick__c, a.partner_service_Provider__c,status__c from Referral_Appointments__r a), Name, First_Name__c,Last_Name__c,Cell_Phone__c,Last_4_digits_of_ssn__c,Referral_Type__c from new_referral_client__c ' ;
    string wherestatement = 'where (OwnerId = ' + '\'' +UserInfo.getuserID() + '\')' + ' and Last_Name__c LIKE \'%'+searchText+'%\'   order by Last_Name__c  ';   
    string qry =   selectstatement + wherestatement;  
     searchResults = Database.query(qry);
     

 

I can update fields Name, First_Name__c,,Last_Name__c etc....

but not  a.Appointment_date__c,a.timepick__c, a.partner_service_Provider__c,status__c which is my subquery.

 

This is where the update occurs

public PageReference save() {
    
   // if (searchResults != null)
    //   {
         
      
           }  
      try
        {
        update searchResults; <- this updates in edit mode
        update ReferralApp1; <- not sure how to update the subquery values in edit mode Thought it would do it by default.

 

Thank You for your help.

 

Steve

 

 

 

 

 


 

bob_buzzardbob_buzzard

The update of the searchresults only writes back that object, it doesn't traverse the related object graph.

 

I would think you should simply be able to write back the related list for this:

 

update searchResults.Referral_Appointments__r;