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
SF7SF7 

An error occurred when processing your submitted information

Hi ,

When i save the record in a LookUp , This weird error comes up. Any idea why this is happening.
<apex:page controller="CustomContactLookupController" title="Search" showHeader="false" sideBar="false" tabStyle="Contact" id="pg">

<apex:form >
<apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel">
 
  <!-- SEARCH TAB -->
<apex:tab label="Contact Search" name="tab1" id="tabOne">
<apex:actionRegion >  
<apex:outputPanel id="top" layout="block" style="margin:1px;padding:10px;padding-top:2px;">
<apex:outputLabel value="{!$Label.OptyContRolePage_Search_Button}" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/>
<apex:inputText id="txtSearch" value="{!searchString}"/>
<span style="padding-left:5px">

<apex:commandButton id="btnGo" value="{!$Label.OptyContRolePage_Go_Button}" action="{!Search}" rerender="searchResults">
</apex:commandButton> </span>

</apex:outputPanel>
 
   <apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;font-size:small" layout="block">
   <apex:outputLabel value="{!$Label.OptyContRolePage_ResultSection}" style="font-weight:Bold;padding-right:10px;"/>
   <br/><br/>
            
  <apex:pageBlock id="searchResults" title="Contacts[{!searchContactCount}]">
   <apex:pageBlockTable value="{!results}" var="a" id="tblResults">
   
<apex:column >
   <apex:facet name="header">
  <apex:outputPanel >Name</apex:outputPanel>
  </apex:facet>
 <apex:outputLink value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!a.Name}',false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Name}</apex:outputLink>     
</apex:column>
                
 <apex:column >
   <apex:facet name="header">
 <apex:outputPanel >Client Name</apex:outputPanel>
  </apex:facet>
 <apex:outputText value="{!a.Account.Name}" rendered="{!NOT(ISNULL(a.Id))}"/>
  </apex:column>
                
                       <apex:column >
                             <apex:facet name="header">
                             <apex:outputPanel >Phone</apex:outputPanel>
                             </apex:facet>
                             <apex:outputText value="{!a.Phone}" rendered="{!NOT(ISNULL(a.Id))}"/>
                       </apex:column>
                
                        <apex:column >
                              <apex:facet name="header">
                              <apex:outputPanel >Email</apex:outputPanel>
                              </apex:facet>
                              <apex:outputText value="{!a.Email}" rendered="{!NOT(ISNULL(a.Id))}"/>
                        </apex:column> 
             </apex:pageBlockTable>
             </apex:pageBlock>
             </apex:outputPanel>
    </apex:actionRegion>
    </apex:tab>
 
<apex:tab label="New Contact" name="tab2" id="tabTwo">
   <apex:pageBlock id="newContact" title="New Contact">
           <apex:pageBlockButtons >
                       <apex:commandButton action="{!SaveContact}" value="Save"/>
           </apex:pageBlockButtons>
          <apex:pageMessages />
                  <apex:pageBlockSection columns="2">

    <apex:repeat value="{!$ObjectType.Contact.FieldSets.CustomContactLookup}" var="f">
                  <apex:inputField value="{!Contact[f]}"/>  
    </apex:repeat>

            <!--    <apex:inputField value="{!Contact.LastName}"/>
                   <apex:inputField value="{!Contact.Email}"/>
                    <apex:inputField value="{!Contact.AccountID}"/> -->

                  </apex:pageBlockSection> 
         </apex:pageBlock>  
     </apex:tab>
     </apex:tabPanel>
     </apex:outputPanel>
     </apex:form>
</apex:page>
 
public with sharing class CustomContactLookupController {
 
 public Contact Contact {get;set;} // new Contact to create
  public List<Contact> results{get;set;} // search results
  public string searchString{get;set;} // search keyword
  public Id ultiAccId;
  public Id localAccId;
  public Integer searchContactCount {get;set;}
  
 
  public CustomContactLookupController() {
    // get the current search string
   
    searchString = System.currentPageReference().getParameters().get('lksrch');
    ultiAccId = System.currentPageReference().getParameters().get('ultimateAccId');
    localAccId= System.currentPageReference().getParameters().get('localAccId');
    runSearch();  
    
  }
 
  // performs the keyword search
  public PageReference search() {
    searchContactCount = 0;
    runSearch();
    return null;
  }
 
  // prepare the query and issue the search command
  private void runSearch() {
    // TODO prepare query string for complex serarches & prevent injections
    results = performSearch(searchString);      
  } 
 
  // run the search and return the records found. 
  private List<Contact> performSearch(string searchString) {
 
    //String[] tokens;
    //String accIds;
    List<Account> SudsidaryAccounts = [select Id from Account where Ultimate_Parent_Client__c =:ultiAccId and id!=null limit 10000];
    List<String> accIds = new List<String>();
    accIds.add(ultiAccId);
    for(Account acc : SudsidaryAccounts) {
        accIds.add(acc.Id);
    }        
    List<contact> conts = [select id, name,AccountId,Email,Phone,Account.Name from Contact where Name LIKE: '%'+searchString +'%' and AccountId IN: accIds];
    searchContactCount = conts.size();
    return conts;
  }
  // save the new Contact record
  public PageReference saveContact() {
  
    insert Contact;
    // reset the Contact
    Contact = new Contact();
    return null;
 }
       
   // used by the visualforce page to send the link to the right dom element
  public string getFormTag() {
    return System.currentPageReference().getParameters().get('frm');
  }
 
  // used by the visualforce page to send the link to the right dom element for the text box
  public string getTextBox() {
    return System.currentPageReference().getParameters().get('txt');
  }
 
}

 
SF7SF7
User-added image