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
vickySFDCvickySFDC 

Inlineeditsupport is not saving record in apex repeat?

Hi All ,
   I have requirement to displaying Rel.event  and rel.contact records  in repeat table.using map collection displaying information.
   Now I have to user able to do inline edit on the Rel.event records and save record.
   But record is not updated in the object and it showing only old values.Pls nedded urgent help on this requirement.
   
   Apex class:
   
   public class Projectmanagment7forbgcolr
{

 // NEW Map collection for display RelationshipEvent and RelationshipContact info
    public Boolean isbtnsave{get;set;}
    public Map<Relationship_Event__c, List<Relationship_Contact__c>> mapEventsAndContacts {get;set;}
    public FTP_Project__c pr{get;set;}
    public list<Relationship_Event__c> lstRelationshipEvents{get;set;}
    
    public list<Relationship_Contact__c> lstRelationshipContacts{get;set;} 
    public string strPriority{get;set;}
    public string searchstring{get;set;}
    public string strNDAStatus{get;set;}
    public string strEvalStatus{get;set;}
    public string strItemsProvided{get;set;}
    public string prjeEmail{get;set;}
    public string prjecoordinator{get;set;}
    public string prjeProjectManager{get;set;}
    public string prjeFTPIntel{get;set;}    
    public decimal prjeContacts{get;set;}  
    public decimal prjActiveEvents{get;set;}
    public decimal prjclosedRelEvents{get;set;}
    public string prcompanyname{get;set;} 
    public string prjename{get;set;}
    public string prjstatus{get;set;}
    public string prcloseddate{get;set;} 
    public string prstartdate{get;set;}
    public FTP_Project__c pr2{get;set;}
    public Relationship_Event__c relev{get;set;} 
    public string strImmediateNextSteps{get;set;}
    public string subCategory{get;set;}
        string pid = apexpages.currentpage().getparameters().get('id');
    public Projectmanagment7forbgcolr()
    {
       
        lstRelationshipEvents=new list<Relationship_Event__c>();
        pr=[select id,Name,Account__r.name,Project_Status__c,Project_Email__c,Project_Start_Date__c,Project_Close_Date__c,FTP_Intelligence__r.name,Closed_Rel_Events__c,Active_Rel_Events2NotApex__c,Contacts__c,Coordinator_and_Manager__c from FTP_Project__c where id=:pid];         
        prjecoordinator=pr.Coordinator_and_Manager__c;
        prjeProjectManager=pr.Coordinator_and_Manager__c;
        prjeFTPIntel=pr.FTP_Intelligence__r.name;
        prjeEmail=pr.Project_Email__c;
        prjclosedRelEvents=pr.Closed_Rel_Events__c;
        prjActiveEvents=pr.Active_Rel_Events2NotApex__c;
        prjeContacts=pr.Contacts__c;   
        string soql='select id, name,B_NDA_Sent_Date__c,ImmediateNextSteps__c,Status_Notes_Next_Steps_External_B__c,T_Initial_Date_Shared__c,B_Follow_Up_Date__c,Strategic_Rationale__c ,B_Due_Diligence_Status__c,Status_Notes_Next_Steps_Internal__c,Potential_Buyer_Investor__r.name,Buyer_Sector__c,Buyers_Investors_Priority__c,Buyer_Evaluation_Status__c,Buyer_Items_Provided__c,Buyer_NDA_Status__c,Buyer_Data_Room__c,Status_Notes_Next_Steps_Internal_B__c,Buyer_Rationale_For_Final_Status__c,B_Scheduled_Meeting_Date__c,B_NDA_Completed_Date__c from Relationship_Event__c where Project__c=: pid ';        
        
         // NEW Map collection for display RelationshipEvent and RelationshipContact info       
          mapEventsAndContacts = new Map<Relationship_Event__c, List<Relationship_Contact__c>>();
          // Query Relationship Event
          List<Relationship_Event__c> lstRelationshipEvents = [select id, name,B_NDA_Sent_Date__c,ImmediateNextSteps__c,Status_Notes_Next_Steps_External_B__c,T_Initial_Date_Shared__c,B_Follow_Up_Date__c,Strategic_Rationale__c ,B_Due_Diligence_Status__c,Status_Notes_Next_Steps_Internal__c,Potential_Buyer_Investor__r.name,Buyer_Sector__c,Buyers_Investors_Priority__c,Buyer_Evaluation_Status__c,Buyer_Items_Provided__c,Buyer_NDA_Status__c,Buyer_Data_Room__c,Status_Notes_Next_Steps_Internal_B__c,Buyer_Rationale_For_Final_Status__c,B_Scheduled_Meeting_Date__c,B_NDA_Completed_Date__c from Relationship_Event__c where Project__c=: pid];
          
          Set<Id> relEventIDs = new Set<Id>();
          
          for(Relationship_Event__c rEvent: lstRelationshipEvents){
              relEventIDs.add(rEvent.Id);
          }
          
          // Query Relationship Contacts 
          List<Relationship_Contact__c> lstRelationshipContacts = [select id,Name,Title__c,Contact__r.name, Phone__c,Email__c,Key_Contact__c, Relationship_Event__c from Relationship_Contact__c where Relationship_Event__c IN : relEventIDs];
          
          for(Relationship_Event__c rEvent: lstRelationshipEvents){
              List<Relationship_Contact__c> tempContacts = new List<Relationship_Contact__c>();
              for(Relationship_Contact__c rContact: lstRelationshipContacts){
                  if(rContact.Relationship_Event__c == rEvent.Id){
                      tempContacts.add(rContact);
                  }
              }
              mapEventsAndContacts.put(rEvent, tempContacts);
          }
          
        pr2=[select  id, name,SetDefault__c,Buyers_Investors_Priority__c,Buyer_Evaluation_Status__c,Buyer_Items_Provided__c,Buyer_NDA_Status__c,FollowSample__c,ImmediateNextSteps__c from FTP_Project__c where id=:pid limit 1]; 
        if(pr2.SetDefault__c == false)
        {
            pr2.ImmediateNextSteps__c=null;
            pr2.Buyers_Investors_Priority__c=null;
            pr2.Buyer_Evaluation_Status__c=null;
            pr2.Buyer_Items_Provided__c=null;
            pr2.Buyer_NDA_Status__c=null;
            pr2.FollowSample__c=null;   
            search();      
        }
    }     
         
    public PageReference search()
    { 
        system.debug('i am inside searchqry');
        string  Mutltipicklistvalues='';
        string pid = apexpages.currentpage().getparameters().get('id');
        string soql = 'Select Id, Name,Potential_Buyer_Investor__r.name,Status_Notes_Next_Steps_External_B__c,B_NDA_Sent_Date__c,ImmediateNextSteps__c,Status_Notes_Next_Steps_External__c,B_Follow_Up_Date__c,T_Initial_Date_Shared__c,B_Due_Diligence_Status__c,Status_Notes_Next_Steps_Internal__c ,Strategic_Rationale__c ,Buyer_Sector__c,Buyers_Investors_Priority__c,Buyer_NDA_Status__c ,Buyer_Data_Room__c,Status_Notes_Next_Steps_Internal_B__c,Buyer_Evaluation_Status__c,Buyer_Rationale_For_Final_Status__c,B_Scheduled_Meeting_Date__c ,Buyer_Items_Provided__c,B_NDA_Completed_Date__c from Relationship_Event__c' ;
        if (!pid.equals(''))
        soql += ' Where  Project__c  =\'' + pid  + '\' ';           
          
        string strImmediateNextSteps = pr2.ImmediateNextSteps__c;                                 
        if(strImmediateNextSteps!=null && strImmediateNextSteps !='' )
        {
            system.debug('$$$$$$$$strImmediateNextSteps'+strImmediateNextSteps);
            soql  =soql  +'and ImmediateNextSteps__c LIKE \'%'+strImmediateNextSteps+'%\'';
            system.debug('$$$$$$$$strImmediateNextSteps1'+ soql); 
        } 
       
        system.debug('pr2.Buyer_Evaluation_Status__c' + pr2.Buyer_Evaluation_Status__c);   
        if(pr2.Buyer_Evaluation_Status__c !='None' && pr2.Buyer_Evaluation_Status__c != null && pr2.Buyer_Evaluation_Status__c != '[]')
        {    
            string temp=pr2.Buyer_Evaluation_Status__c.replace(',','\',\'');
            system.debug('I am inside pr2.Buyer_Evaluation_Status__c' + temp);
            temp= '\''+ temp + '\'';
            string temp1=temp.replace('[','');
            string value=temp1.replace(']','');
            string trimmedValue=value.replace('\' ','\'');
            system.debug('I am inside type' + trimmedValue);
            soql  += ' and Buyer_Evaluation_Status__c IN ( '+ trimmedValue+ ')';          
        }
          
        system.debug('pr2.Buyer_NDA_Status__c' + pr2.Buyer_NDA_Status__c);
        if(pr2.Buyer_NDA_Status__c !='None' && pr2.Buyer_NDA_Status__c != null && pr2.Buyer_NDA_Status__c != '[]')
        {    
            string temp=pr2.Buyer_NDA_Status__c.replace(',','\',\'');
            system.debug('I am inside pr2.Buyer_NDA_Status__c' + temp);
            temp= '\''+ temp + '\'';
            string temp1=temp.replace('[','');
            string value=temp1.replace(']','');
            string trimmedValue=value.replace('\' ','\'');
            system.debug('I am inside type' + trimmedValue);
            soql  += ' and Buyer_NDA_Status__c IN ( '+ trimmedValue+ ')';          
        }
          
        system.debug('pr2.Buyers_Investors_Priority__c' + pr2.Buyers_Investors_Priority__c);
        if(pr2.Buyers_Investors_Priority__c !='None' && pr2.Buyers_Investors_Priority__c != null && pr2.Buyers_Investors_Priority__c != '[]')
        {    
             string temp=pr2.Buyers_Investors_Priority__c.replace(',','\',\'');
             system.debug('I am inside pr2.Buyers_Investors_Priority__c' + temp);
             temp= '\''+ temp + '\'';
             string temp1=temp.replace('[','');
             string value=temp1.replace(']','');
             string trimmedValue=value.replace('\' ','\'');
             system.debug('I am inside type' + trimmedValue);
             soql  += ' and Buyers_Investors_Priority__c IN ( '+ trimmedValue+ ')';           
        }
           
        system.debug('pr2.Buyer_Items_Provided__c' + pr2.Buyer_Items_Provided__c);
        if(pr2.Buyer_Items_Provided__c != 'None' && pr2.Buyer_Items_Provided__c != null && pr2.Buyer_Items_Provided__c != '[]')  
        {   
            List<String> setString=pr2.Buyer_Items_Provided__c.split(',');
            if(setString.size() > 0 )
                {
                string s='';
                integer i=0;
                for(String val: setString)
                {
                    if(i == setstring.size() -1)
                    {
                      s+='\''+val+'\'';
                    }
                    else
                    {
                     s+='\''+val+'\',';
                    }
                    i++;
                }       
                system.debug('ssssssssssssssssss'+s);
                String [] values = s.split(',');
                String param='(';
                for(integer j=0;j<values.size();j++)
                {  
                    if(values.size()-1 == j)
                        {
                            param += values[j];      
                        }
                        else
                        {
                               param += values[j]+',';
                         
                         }
                }   
                    param +=')';
                    param = param.remove('[');
                    param = param.remove(']');       
                    Mutltipicklistvalues=param ;
                    system.debug('param::::::'+Mutltipicklistvalues);
                }
    
                  if (!Mutltipicklistvalues.equals(''))
                  {                                                     
                    soql += ' and Buyer_Items_Provided__c includes    ' + Mutltipicklistvalues  + '';
                  }
                      system.debug('soql______'+soql);    
            }
            List<Relationship_Event__c> lstRelationshipEvents = Database.query(soql);
            
            // NEW Map collection for display RelationshipEvent and RelationshipContact info       
            mapEventsAndContacts = new Map<Relationship_Event__c, List<Relationship_Contact__c>>();
          
            Set<Id> relEventIDs = new Set<Id>();
          
            for(Relationship_Event__c rEvent: lstRelationshipEvents){
                relEventIDs.add(rEvent.Id);
            }       
            // Query Relationship Contacts 
            List<Relationship_Contact__c> lstRelationshipContacts = [select id,Name,Title__c,Contact__r.name, Phone__c,Email__c,Key_Contact__c, Relationship_Event__c from Relationship_Contact__c where Relationship_Event__c IN : relEventIDs];
            
            for(Relationship_Event__c rEvent: lstRelationshipEvents){
              List<Relationship_Contact__c> tempContacts = new List<Relationship_Contact__c>();
              for(Relationship_Contact__c rContact: lstRelationshipContacts){
                  if(rContact.Relationship_Event__c == rEvent.Id){
                      tempContacts.add(rContact);
                  }
              }
              mapEventsAndContacts.put(rEvent, tempContacts);
            } 
            system.debug('search ends'+ Mutltipicklistvalues);   
            return null;
    }
    //Inline edit method
    public PageReference btnsave() {
        List<Relationship_Event__c> lstEvents_Update = new List<Relationship_Event__c>();
        // Need to check all updated values from MAP collection
        for(Relationship_Event__c rEvents : mapEventsAndContacts.keySet()){
            lstEvents_Update.add(rEvents);
            system.Debug(' Changes ==>'+rEvents.Buyers_Investors_Priority__c);
        }
        //isbtnsave=true; //????
        update lstEvents_Update;
        //System.debug('@@@@@@'+lstEvents_Update);
        System.debug('########'+lstEvents_Update.size());
        return null;
    }
    }
    
Page:
<apex:pageBlock>
<table>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!btnsave}" id="savebtn" />        
</apex:pageBlockButtons>
<apex:repeat value="{!mapEventsAndContacts}" var="rel" >
<apex:inlineEditSupport event="ondblclick" showOnEdit="savebtn"
changedStyleClass="myBoldClass"/>                               
<!--Expansion and collaspse of a particular row starts here -->
<tr  class="Capital1 exapnding odd even" style="margin-top: 0px;text-align:left; font-family:arial; margin-bottom:0px;border-bottom: 3px solid black;">
<td id="tid" onclick="toggle(event);" style="cursor:pointer;padding-left:4px;">
<b> {!rel.Potential_Buyer_Investor__r.name}</b>
</td>
<td class="priortyid" style="cursor:pointer;padding-left:4px;">
{!rel.Buyers_Investors_Priority__c}    
</td>
<td class="evalstsid" style="cursor:pointer;padding-left:4px;">
{!rel.Buyer_Evaluation_Status__c}
</td> 
<td style="width:9%;">
<table style="width:100%;">
<tr style="width: 50%;">                   
<td style="cursor:pointer;text-align:left;width: 50%;border: none;"> 
<span><b>Status:</b></span>
<div class="statusid" style="cursor:pointer;">
    &nbsp;{!rel.Buyer_NDA_Status__c}
</div>  
</td>
<td style="cursor:pointer;text-align:left;width: 50%;border: none;"> 
<span><b>Sent:</b></span>
<div class="Completedid" > 
<apex:outputText value="{0,date,MM.dd.yyyy}"> 
   &nbsp;<apex:param value="{!rel.B_NDA_Sent_Date__c}" /> 
</apex:outputText>  
</div>
</td>                        
</tr>
<tr style="width: 50%;">                    
<td style="cursor:pointer;text-align:left;width: 100%;border: none;"> 
<span><b>Completed:</b></span>
<div class="Sentid">
    <apex:outputText value="{0,date,MM.dd.yyyy}" style="width: 81px;"> 
        &nbsp;<apex:param value="{!rel.B_NDA_Completed_Date__c}" />         
    </apex:outputText>  
</div>   
</td>
</tr>
</table>
</td>
<td style="width:10%;">
<table style="width:100%;">
<tr style="width: 100%;">
<td style="cursor:pointer;text-align:left;width: 50%;border: none;"> 
<span><b>Status:</b></span>
<div class="BuyerStatusid" style="cursor:pointer;">
    {!rel.Buyer_Data_Room__c}
</div>  
</td>
<td style="cursor:pointer;text-align:left;width: 50%;border: none;"> 
<span><b>Due Dil Status:</b></span>
<div class="DueDilid" style="cursor:pointer;">
    &nbsp;{!rel.B_Due_Diligence_Status__c}
</div> 
</td>
</tr>
</table>
</td>
 
</tr>
<tr id="divid3" class="no_outline_tr ExpandToggle exapnding"  style="display:none;border-style: solid;border-width: 1px;width:100%;background-color:white;">
<td colspan="11"  style="border:1px solid black;border-bottom:2px solid black;">
<table class="no_outline"  style="border-width: 1px;border-top:1px #C0BFBD;margin-top:-2px;width: 100.3%;margin-left: -2px;">
<tr >
<td colspan="11" style="line-height: 25px;padding-top: 0px;">
<span> <b>&nbsp;Current Status / Next Steps:</b></span> 
<div  class="externalid" style="border-bottom:1px solid black;cursor:pointer;line-height:20px;margin:0px -3px;"> 
    &nbsp;{!rel.Status_Notes_Next_Steps_External_B__c}
</div>
</td>
</tr>
<tr>
<td colspan="11" style="line-height: 25px;padding-top: 0px;">
<span ><b>&nbsp;Current Status / Next Steps (INTERNAL):</b></span> 
<div class ="stnotes" style="border-bottom:1px solid black;cursor:pointer;line-height:20px;padding:0px 5px;margin:0px -3px;"> 
    &nbsp;{!rel.Status_Notes_Next_Steps_Internal_B__c}
</div>
</td>
</tr>
<tr>
<td colspan="11" style="line-height: 20px;padding-top: 0px;"> 
<span><b>&nbsp;Strategic Rationale:</b></span>
<div class="Strategicid" style="cursor:pointer;padding:0px 5px;margin:0px -3px;border-bottom:1px solid black;"> 
    &nbsp;{!rel.Strategic_Rationale__c}
</div>
</td>
</tr>
</table>
<div id="divid4" style="border-width:1px;width:100.3%;border-top:none;margin-top:-1px;margin-left: -2px; padding-right: 2px;">
<span class="viewid2"  onclick="Showcontact(event);"  style="color:blue;cursor:pointer;margin:4px;font-family:arial;"><b>View Contact</b></span> 
<div id="dispcontact2" class="contactshow"  style="display:none;color:blue;cursor:pointer;"><span class="hideTextSpan" onclick="Hidecontact(event);" style="font-family:arial;"><b>&nbsp;&nbsp;Hide Contact</b></span>                                     
<table id="InnerTableGrid" class="innertablecontacts thauf" style="font-family:arial;">
<tbody style="text-align:center;">
<apex:repeat value="{!mapEventsAndContacts[rel]}" var="relcon" id="p2"> 
<!--<apex:repeat value="{!relcontact}" var="relcon" > -->
<tr style="text-align:center;height: 36px;">
<td>
    &nbsp;{!relcon.Contact__r.Name}  
</td>
<td>
    &nbsp; {!relcon.Title__c}
</td>
<td>
    &nbsp;    
</td>
<td>
    &nbsp; {!relcon.Phone__c}
</td>
<td>
    &nbsp;
</td>
<td >
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{!relcon.Email__c} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td>
    &nbsp; {!relcon.Key_Contact__c}
</td>
</tr>
</apex:repeat>
</tbody>              
</table> 
</div>
</div> 
</td>
</tr>      
</apex:repeat>
</tbody>

</table>
</apex:pageBlock>
​Thanks   
    
Andy BoettcherAndy Boettcher
You need to use apex:inputText or apex:inputField (inputField preferably) to get those values to cross back to the controller via viewstate on the submit.

Outside of that - you can use Javascript remoting to manually assemble the new values and push back to the controller if you want to keep the non-VF component thing going.
vickySFDCvickySFDC
Thank you I will check it and try in Apex remote function