• SF_DEV_CDE
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies
Not able to get Account id with the below code, can any one help me here


 public with sharing class accsearchconroller {
    
    transient public list <account> acc {get;set;}  
    public string searchstring {get;set;}  
    transient List<Account> AllAccountRecs = new List<Account>();
    public List<Facility__c> allfacilities = new list<Facility__c>();
  
  //constructor do nothing for now 
   public accsearchconroller() {

    }              
    //Searching method with string
    public void search(){ 
    if (searchstring == null || searchstring.length()==0) {
    ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Please Enter the account Id to Search' );
      ApexPages.addmessage(msg);
           
      }else if(searchstring != null && searchstring.length()<=4) {
          ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Search text should have atleast 5 characters' );
      ApexPages.addmessage(msg);
             }
             
       else if(searchstring != null && searchstring.length()>4){
       string bid='Residual';
      string searchquery='select name,id,owner.name,recordtype.name from account where name like \'%'+searchstring+'%\''; 
      
      acc= Database.query(searchquery);     
     
      } 
   }     
   public void clear(){
     if(acc.size()!=0){
       acc = null;
   }
   }  
   //   for facility deisplay
      public void getallfac(){     
         String aId = ApexPages.currentPage().getParameters().get('acctId');     
     system.debug('***********************************************'+aId);    
         if(aId == null){            
           // return null;
         }
         else{
         allfaces = [select Id,Name From Facility__c where Account__c = :ApexPages.currentPage().getParameters().get('acctId')];}
         //return allfacilities;
     }   
   
}


Page: 



<apex:page Controller="accsearchconroller" sidebar="false" readOnly="true" tabStyle="Account">
   <!--to reset/clear button - java script-->
   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
         <script type="text/javascript">
            function resetForm(ele) {
                 $(ele).closest('form').find("input[type=text], textarea").val("");
                return false;
          }
   </script>
   
  <apex:pageMessages id="msg" />
   <apex:form id="formid">  
  
      <center><B>
      <h5>  Account ID </h5>
      <apex:inputText value="{!searchstring}" label="Input" />
      <apex:commandButton value="Search Account" action="{!search}" />    
      <apex:commandButton value="Clear/Reset" onclick="return resetForm(this);" action="{!clear}" rerender="pbtable" immediate="true"/>  </B>
      </center>
      <h5 style="text-align:right;color:black;">
     <apex:outputText >  Please Enter full name/exact Id of the account for narrowing your search results </apex:outputText> </h5>
  <!--Page block starts-->
  
   <apex:pageBlock title="Search Results" id="pageblock1" >  
    <apex:pageblockTable value="{!acc}" var="a" rendered="{!acc.size!=null}" id="pbtable1">
    <apex:inputHidden value="{!a.Id}" id="acctId">  
    <apex:param name="acctId" value="{!a.Id}"/>
    </apex:inputHidden>     
    <apex:column headerValue="Account Name" >  
      <apex:outputlink value="/{!a.id}">{!a.Name}</apex:outputlink>  
     </apex:column>  
     <apex:column headerValue="Owner" value="{!a.owner.name}"/>  
     <apex:column headerValue="RecordType Name" value="{!a.recordtype.name}" />
     </apex:pageBlockTable>     
    </apex:pageBlock>  
  
 <apex:pageBlock title="Account - Faces" id="pageblock2">
  <apex:commandButton value="Diaplsy Faces" action="{!getallfac}"/>
    <apex:pageblockTable value="{!allfaces}" var="f" rendered="{!allfaces.size!=null}" id="pbtable2">   
    <apex:column headerValue="Facility Name" >  
      <apex:outputlink value="/{!f.id}">{!f.Name}</apex:outputlink>  
     </apex:column>          
    </apex:pageBlockTable>     
   </apex:pageBlock>
   
  </apex:form>
</apex:page>
Hi 
I have the code as below :

My Page:

<apex:page standardController="Account" extensions="accsearchconroller" sidebar="false" readOnly="true">
   <!--to reset/clear button - java script-->
   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
         <script type="text/javascript">
            function resetForm(ele) {
                 $(ele).closest('form').find("input[type=text], textarea").val("");
                return false;
          }
   </script>
   
  <apex:pageMessages id="msg" />
   <apex:form id="formid">  
  
      <center><B>
      <apex:inputText value="{!searchstring}" label="Input" />
      <apex:commandButton value="Search Account" action="{!search}" />    
      <apex:commandButton value="Clear/Reset" onclick="return resetForm(this);" action="{!clear}" rerender="pbtable" immediate="true"/>  </B>
      </center>
      <h5 style="text-align:right;color:black;">
     <apex:outputText >  Please Enter full name/exact Account ID of the account for narrowing your search results </apex:outputText> </h5>
  <!--Page block starts-->
  
   <apex:pageBlock title="Search Result" id="pageblock" >  
    <apex:pageblockTable value="{!acc}" var="a" rendered="{!acc.size!=null}" id="pbtable">
     <apex:column headerValue="Account Name" >  
      <apex:outputlink value="/{!a.id}">{!a.Name}</apex:outputlink>  
     </apex:column>  
     <apex:column headerValue="Owner" value="{!a.owner.name}"/>  
     <apex:column headerValue="RecordType Name" value="{!a.recordtype.name}" />
     <apex:column headerValue="Bid Type" value="{!a.Bid_Type__c}"/>
      <apex:column headerValue="Faculty(s)" value="{!a.AAA_Faculty__c}"/>
    </apex:pageBlockTable>     
   </apex:pageBlock> 
   <apex:pageBlock >
    <apex:pageBlockSection title="Faculty">
       <apex:commandButton value="Display Faculty" action="{!faculties}" />  &nbsp;&nbsp; 
       <apex:pageblockTable value="{!faculty}" var="f" rendered="{!faculties.size!=null}" id="pbtable1"> 
        <apex:column headerValue="FacultyName" >  
         <apex:outputlink value="/{!f.id}">{!f.Name}</apex:outputlink>  
        </apex:column>  
           
       </apex:pageBlockTable> 
      </apex:pageBlockSection>
   </apex:pageBlock> 
  </apex:form>   
</apex:page>

My Controller:

 public with sharing class accsearchconroller {
   
    transient public list <account> acc {get;set;}  
    public string searchstring {get;set;}  
    public list <Faculty__c> faculties{get;set;}
    public String currentRecordId {get;set;}
   
   
     //constructor do nothing for now

    public accsearchconroller(ApexPages.StandardController controller) {
    

    }
   
    
    //Searching method with string
    public void search(){ 
    if (searchstring == null || searchstring.length()==0) {
    ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Please Enter the account Id to Search' );
      ApexPages.addmessage(msg);
           
      }else if(searchstring != null && searchstring.length()<=4) {
    ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Search text should have atleast 5 characters' );
      ApexPages.addmessage(msg);
             }
             
       else if(searchstring != null && searchstring.length()>4){
      string searchquery='select name,id,owner.name,recordtype.name,Bid_Type__c,SpareFoot_Account_Id__c,AAA_Faculty__c from account where (Bid_Type__c !=null AND SpareFoot_Account_Id__c like \'%'+searchstring+'%\')';  
      acc= Database.query(searchquery); } 
   }
     
   public void clear(){
   
   if(acc.size()!=0){
       acc = null;
   }
   }  
     //   for facility display
    public void faculties(){
    
     currentRecordId  = ApexPages.CurrentPage().getparameters().get('AccountId');
     faculties=[select id,name from Faculty__c where Account__c=:currentRecordId order by Name asc limit 30];
    }
 
}

And i wante to display the Faculties based on account id , but the above code is not working 

only account search is correct after that to display faculties - its not working , Please help on it.


Thanks
sweta

Hi All

 

Need help on Trigger ,

 

My scenario is : I have a text field(jobNumber)  and a Lookup Field(Job),Job field to be updated by Job Number (Need to get  a name of the Number in the lookup)and It contains more than one value(normally it contains jobnumber1;jobnumber2;jobnumber3; etc),needs to update lookup field with the first value of Job Number.

 

 

Not able to get Account id with the below code, can any one help me here


 public with sharing class accsearchconroller {
    
    transient public list <account> acc {get;set;}  
    public string searchstring {get;set;}  
    transient List<Account> AllAccountRecs = new List<Account>();
    public List<Facility__c> allfacilities = new list<Facility__c>();
  
  //constructor do nothing for now 
   public accsearchconroller() {

    }              
    //Searching method with string
    public void search(){ 
    if (searchstring == null || searchstring.length()==0) {
    ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Please Enter the account Id to Search' );
      ApexPages.addmessage(msg);
           
      }else if(searchstring != null && searchstring.length()<=4) {
          ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Search text should have atleast 5 characters' );
      ApexPages.addmessage(msg);
             }
             
       else if(searchstring != null && searchstring.length()>4){
       string bid='Residual';
      string searchquery='select name,id,owner.name,recordtype.name from account where name like \'%'+searchstring+'%\''; 
      
      acc= Database.query(searchquery);     
     
      } 
   }     
   public void clear(){
     if(acc.size()!=0){
       acc = null;
   }
   }  
   //   for facility deisplay
      public void getallfac(){     
         String aId = ApexPages.currentPage().getParameters().get('acctId');     
     system.debug('***********************************************'+aId);    
         if(aId == null){            
           // return null;
         }
         else{
         allfaces = [select Id,Name From Facility__c where Account__c = :ApexPages.currentPage().getParameters().get('acctId')];}
         //return allfacilities;
     }   
   
}


Page: 



<apex:page Controller="accsearchconroller" sidebar="false" readOnly="true" tabStyle="Account">
   <!--to reset/clear button - java script-->
   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
         <script type="text/javascript">
            function resetForm(ele) {
                 $(ele).closest('form').find("input[type=text], textarea").val("");
                return false;
          }
   </script>
   
  <apex:pageMessages id="msg" />
   <apex:form id="formid">  
  
      <center><B>
      <h5>  Account ID </h5>
      <apex:inputText value="{!searchstring}" label="Input" />
      <apex:commandButton value="Search Account" action="{!search}" />    
      <apex:commandButton value="Clear/Reset" onclick="return resetForm(this);" action="{!clear}" rerender="pbtable" immediate="true"/>  </B>
      </center>
      <h5 style="text-align:right;color:black;">
     <apex:outputText >  Please Enter full name/exact Id of the account for narrowing your search results </apex:outputText> </h5>
  <!--Page block starts-->
  
   <apex:pageBlock title="Search Results" id="pageblock1" >  
    <apex:pageblockTable value="{!acc}" var="a" rendered="{!acc.size!=null}" id="pbtable1">
    <apex:inputHidden value="{!a.Id}" id="acctId">  
    <apex:param name="acctId" value="{!a.Id}"/>
    </apex:inputHidden>     
    <apex:column headerValue="Account Name" >  
      <apex:outputlink value="/{!a.id}">{!a.Name}</apex:outputlink>  
     </apex:column>  
     <apex:column headerValue="Owner" value="{!a.owner.name}"/>  
     <apex:column headerValue="RecordType Name" value="{!a.recordtype.name}" />
     </apex:pageBlockTable>     
    </apex:pageBlock>  
  
 <apex:pageBlock title="Account - Faces" id="pageblock2">
  <apex:commandButton value="Diaplsy Faces" action="{!getallfac}"/>
    <apex:pageblockTable value="{!allfaces}" var="f" rendered="{!allfaces.size!=null}" id="pbtable2">   
    <apex:column headerValue="Facility Name" >  
      <apex:outputlink value="/{!f.id}">{!f.Name}</apex:outputlink>  
     </apex:column>          
    </apex:pageBlockTable>     
   </apex:pageBlock>
   
  </apex:form>
</apex:page>
Hi 
I have the code as below :

My Page:

<apex:page standardController="Account" extensions="accsearchconroller" sidebar="false" readOnly="true">
   <!--to reset/clear button - java script-->
   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
         <script type="text/javascript">
            function resetForm(ele) {
                 $(ele).closest('form').find("input[type=text], textarea").val("");
                return false;
          }
   </script>
   
  <apex:pageMessages id="msg" />
   <apex:form id="formid">  
  
      <center><B>
      <apex:inputText value="{!searchstring}" label="Input" />
      <apex:commandButton value="Search Account" action="{!search}" />    
      <apex:commandButton value="Clear/Reset" onclick="return resetForm(this);" action="{!clear}" rerender="pbtable" immediate="true"/>  </B>
      </center>
      <h5 style="text-align:right;color:black;">
     <apex:outputText >  Please Enter full name/exact Account ID of the account for narrowing your search results </apex:outputText> </h5>
  <!--Page block starts-->
  
   <apex:pageBlock title="Search Result" id="pageblock" >  
    <apex:pageblockTable value="{!acc}" var="a" rendered="{!acc.size!=null}" id="pbtable">
     <apex:column headerValue="Account Name" >  
      <apex:outputlink value="/{!a.id}">{!a.Name}</apex:outputlink>  
     </apex:column>  
     <apex:column headerValue="Owner" value="{!a.owner.name}"/>  
     <apex:column headerValue="RecordType Name" value="{!a.recordtype.name}" />
     <apex:column headerValue="Bid Type" value="{!a.Bid_Type__c}"/>
      <apex:column headerValue="Faculty(s)" value="{!a.AAA_Faculty__c}"/>
    </apex:pageBlockTable>     
   </apex:pageBlock> 
   <apex:pageBlock >
    <apex:pageBlockSection title="Faculty">
       <apex:commandButton value="Display Faculty" action="{!faculties}" />  &nbsp;&nbsp; 
       <apex:pageblockTable value="{!faculty}" var="f" rendered="{!faculties.size!=null}" id="pbtable1"> 
        <apex:column headerValue="FacultyName" >  
         <apex:outputlink value="/{!f.id}">{!f.Name}</apex:outputlink>  
        </apex:column>  
           
       </apex:pageBlockTable> 
      </apex:pageBlockSection>
   </apex:pageBlock> 
  </apex:form>   
</apex:page>

My Controller:

 public with sharing class accsearchconroller {
   
    transient public list <account> acc {get;set;}  
    public string searchstring {get;set;}  
    public list <Faculty__c> faculties{get;set;}
    public String currentRecordId {get;set;}
   
   
     //constructor do nothing for now

    public accsearchconroller(ApexPages.StandardController controller) {
    

    }
   
    
    //Searching method with string
    public void search(){ 
    if (searchstring == null || searchstring.length()==0) {
    ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Please Enter the account Id to Search' );
      ApexPages.addmessage(msg);
           
      }else if(searchstring != null && searchstring.length()<=4) {
    ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Search text should have atleast 5 characters' );
      ApexPages.addmessage(msg);
             }
             
       else if(searchstring != null && searchstring.length()>4){
      string searchquery='select name,id,owner.name,recordtype.name,Bid_Type__c,SpareFoot_Account_Id__c,AAA_Faculty__c from account where (Bid_Type__c !=null AND SpareFoot_Account_Id__c like \'%'+searchstring+'%\')';  
      acc= Database.query(searchquery); } 
   }
     
   public void clear(){
   
   if(acc.size()!=0){
       acc = null;
   }
   }  
     //   for facility display
    public void faculties(){
    
     currentRecordId  = ApexPages.CurrentPage().getparameters().get('AccountId');
     faculties=[select id,name from Faculty__c where Account__c=:currentRecordId order by Name asc limit 30];
    }
 
}

And i wante to display the Faculties based on account id , but the above code is not working 

only account search is correct after that to display faculties - its not working , Please help on it.


Thanks
sweta

Hi All

 

Need help on Trigger ,

 

My scenario is : I have a text field(jobNumber)  and a Lookup Field(Job),Job field to be updated by Job Number (Need to get  a name of the Number in the lookup)and It contains more than one value(normally it contains jobnumber1;jobnumber2;jobnumber3; etc),needs to update lookup field with the first value of Job Number.