• Rajendra O
  • NEWBIE
  • 110 Points
  • Member since 2008
  • Senior Software Engineer


  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 26
    Replies

<apex:page controller="ContactSearchController" >
<apex:form >
    <apex:pageMessages />
    <apex:pageBlock title="Enter Inputs">
        <apex:pageBlockButtons location="bottom">
            <apex:commandButton action="{!Searchresult}" value="Search"/>
        </apex:pageBlockButtons>
        <apex:pageblockSection >
            <apex:inputField value="{!c.Lastname}"/>
            <apex:inputField value="{!c.Phone}"/>
            <apex:inputField value="{!c.Email}"/>
            <apex:inputField value="{!c.AccountId}"/> 
        </apex:pageblockSection>    
    </apex:pageBlock>
    <apex:pageblock title="Search Results" rendered="{!showsearchresults}">
        <apex:pageblockTable value="{!conList}" var="c">
            <apex:column value="{!c.lastname}"/>
            <apex:column value="{!c.phone}"/>
            <apex:column value="{!c.email}"/>
            <apex:column value="{!c.accountId}"/>
        </apex:pageblockTable>
    </apex:pageblock>
</apex:form>
</apex:page>

 

public class ContactSearchController{
    public Contact C {get;set;}
    public list<contact> conList{get;set;}
    public boolean showsearchresults{get;set;}
    public ContactSearchController(){
        //C = new Contact();
      
        showsearchresults=false;
    }
    public pagereference Searchresult(){
          C = new Contact();
          conList=new list<contact>();
       if(c.Lastname== null || c.Lastname=='' && c.Email==null || c.Email=='' && c.Phone==null || c.Phone =='' && c.AccountId==null || c.AccountId ==''){
            System.debug('Value of lastname'+ c.Lastname);
            System.debug('Value of Email'+ c.Email);
            System.debug('Value of Phone'+ c.Phone);
            System.debug('Value of AccountId'+ c.AccountId);           
             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Please enter values for all input fields'));
                showSearchResults=false;
                return null;
        }
        System.debug('Size of list of contacts before SOQL'+conList.size());
        conList = [Select lastname,email,phone,accountId from Contact where (lastname=:c.Lastname and email=:c.Email and phone=:c.Phone and accountId=:c.AccountId)and (lastname !=null and email!=null and phone!=null and accountId!=null)];
           System.debug('Size of list of contacts after SOQL'+conList.size());
           System.debug('values of list of contacts after SOQL'+conList);
        if(conList.size()==0){
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'No matching Contact record found');
            ApexPages.addMessage(myMsg);
            showSearchResults=false;
                return null;
        }
        else if(conList.size()>0){
            showSearchResults=true;
                return null;
        }
        return null;
    }
}

Please help in finding the right approach.

Current Scenario, i have a mysql database which i wanted to move all the data and users to Salesforce.. here are the table details

Client Table  . Each client will be assigned one or more department like software, QA,PHP etc.  Many custom fields

Admin users table : Main admin with acess to all cleint.. Some users will be assigned more or one department and accordingly he will have acess to respective clients.

Client_department table : in this we have to collect more information department wise which will be linked with client id from clients table

Cleint_department_xref table : in this we have to collect information department wise which can occur more than once for each cleint id.

Cases table : in this we want to create ticket or cases each client wise

All tables have custom fields . so need to know what is the best approach to setup database and respective forms in salesforce.

Do we have to use default sobject or do we have to create custom object or a combination of  both.
Not sure where to start
sum__c field in contact and total_sum__c field in account
for all the contact fr a particular account 
i want the total sum to be displayed in total_sum__c field
like in 1 contact sum__c field has 10
in other contact sum__c field is 20
so total_sum__c should be 30

i dont want to use aggregate funt and roll up summary?
any idea


trigger sum_Total_Sum on Contact (after insert,after update ,after delete)
{
    set<id> conAccId = new set<id>();
   
              if(trigger.isInsert || trigger.isUpdate)
              {
                  for(contact c : trigger.new)
                    {
                          conAccId.add(c.AccountId);
                     
                    }
               }
      
      
            if(trigger.isDelete)
            {
               for(contact c: trigger.old)
                {
                conAccId.add(c.AccountId);
                }
            }
           
       
      List<account> accountToUpdate = new List<account>();
     
 
       for( account ac :[select id,(select id, Sum__c from contacts ) from account  where id IN : conAccId ])
        {
                      
                      
                     ac.Total_Sum__c =ac.Total_Sum__c + c.Sum__c;
                   
                    accountToUpdate.add(ac);
              
        }
     update accountToUpdate;
    
  }
I have a page that defines an inputText component with required="true" but when the page renders, the input box doesn't have the red bar indicating that it's required.

My page looks like this:

<apex:page standardController="Contact">
<apex:form >
  <apex:outputLabel value="Birthdate" />
  <apex:inputText value="{!Contact.birthdate}" required="true" />
</apex:form>
</apex:page>

 When the page is displayed, the vertical red "required" bar doesn't precede the input box.

If I add a Save button to the page and click it, the field does act as if a value is required. (Contact.Birthdate is required in my org). The problem is that the UI doesn't display the "required" visual cue.

This is pretty simple stuff. What am I doing wrong?

Jeri


Hi All,

I have created a new Lookup field on standard Prdoduct object which points to one of my custom objects. Field has been created successfully but when I'm trying to set  a value by clicking the magnifying glass the popup doesn't show any records of my Custom object. 
As suggested in some other posts I checked for Search settings in Setup > Customize > Search > Search Settings. Custom objects has been enabled for enhance search at there. Can anyone help me to figure out what is going on please?

Thanks,
Madhura
Hi,

I have written a trigger in which fields are updated based on previous record.  In the test class thus i need to insert 2 records with a delay in between them. So that the 1st record is created and based on that the next record should be updated.

Thanks in advance!

created a custom object called bank,how do i create an controller and vfp for creating a new record for bank object. all ready i have list,edit,delete functions in the controller.

*new to salesforce.

 

 

Hey Friend,
I m Creating Different page layout for (Issue) Object name , i want to viewd that different page layout with its same object Fields???
Hi,

I'm writing a delete trigger and that is bulkify too. I'm not getting the way to prevent valid data of being delete. like for example if I have 10 record to delete and 2 of them are valid or supposed not to be deleted by anyone. so my use case is those 2 recoreds should will not be deleted . and rest all (8) can be deleted easily.

so if anyone knows about it then please let me know. thanks in advance.
Hi Guys,

I am displaying data using StandardSetController and pagination, but when i want to export the data, it displaying only current page data but i want all data to be excel.How to achieve it.

Below is the code i am using to display to data.

public ApexPages.StandardSetController contoller{get; set;}

controller = new ApexPages.StandardSetController(Database.getQueryLocator(finalQuery));
               
 controller.setPageSize(200);

           public Boolean hasNext
            {
               get
               {
                     return controller.getHasNext();
               }
              set;
            }  
        
            public Boolean hasPrevious
            {
               get
               {
                   return controller.getHasPrevious();
               }
               set;
            }
Suggest me any idea how to achieve it.

Thanks,
Bujji

  • August 07, 2014
  • Like
  • 0

<apex:page controller="ContactSearchController" >
<apex:form >
    <apex:pageMessages />
    <apex:pageBlock title="Enter Inputs">
        <apex:pageBlockButtons location="bottom">
            <apex:commandButton action="{!Searchresult}" value="Search"/>
        </apex:pageBlockButtons>
        <apex:pageblockSection >
            <apex:inputField value="{!c.Lastname}"/>
            <apex:inputField value="{!c.Phone}"/>
            <apex:inputField value="{!c.Email}"/>
            <apex:inputField value="{!c.AccountId}"/> 
        </apex:pageblockSection>    
    </apex:pageBlock>
    <apex:pageblock title="Search Results" rendered="{!showsearchresults}">
        <apex:pageblockTable value="{!conList}" var="c">
            <apex:column value="{!c.lastname}"/>
            <apex:column value="{!c.phone}"/>
            <apex:column value="{!c.email}"/>
            <apex:column value="{!c.accountId}"/>
        </apex:pageblockTable>
    </apex:pageblock>
</apex:form>
</apex:page>

 

public class ContactSearchController{
    public Contact C {get;set;}
    public list<contact> conList{get;set;}
    public boolean showsearchresults{get;set;}
    public ContactSearchController(){
        //C = new Contact();
      
        showsearchresults=false;
    }
    public pagereference Searchresult(){
          C = new Contact();
          conList=new list<contact>();
       if(c.Lastname== null || c.Lastname=='' && c.Email==null || c.Email=='' && c.Phone==null || c.Phone =='' && c.AccountId==null || c.AccountId ==''){
            System.debug('Value of lastname'+ c.Lastname);
            System.debug('Value of Email'+ c.Email);
            System.debug('Value of Phone'+ c.Phone);
            System.debug('Value of AccountId'+ c.AccountId);           
             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Please enter values for all input fields'));
                showSearchResults=false;
                return null;
        }
        System.debug('Size of list of contacts before SOQL'+conList.size());
        conList = [Select lastname,email,phone,accountId from Contact where (lastname=:c.Lastname and email=:c.Email and phone=:c.Phone and accountId=:c.AccountId)and (lastname !=null and email!=null and phone!=null and accountId!=null)];
           System.debug('Size of list of contacts after SOQL'+conList.size());
           System.debug('values of list of contacts after SOQL'+conList);
        if(conList.size()==0){
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'No matching Contact record found');
            ApexPages.addMessage(myMsg);
            showSearchResults=false;
                return null;
        }
        else if(conList.size()>0){
            showSearchResults=true;
                return null;
        }
        return null;
    }
}

Please help in finding the right approach.

Current Scenario, i have a mysql database which i wanted to move all the data and users to Salesforce.. here are the table details

Client Table  . Each client will be assigned one or more department like software, QA,PHP etc.  Many custom fields

Admin users table : Main admin with acess to all cleint.. Some users will be assigned more or one department and accordingly he will have acess to respective clients.

Client_department table : in this we have to collect more information department wise which will be linked with client id from clients table

Cleint_department_xref table : in this we have to collect information department wise which can occur more than once for each cleint id.

Cases table : in this we want to create ticket or cases each client wise

All tables have custom fields . so need to know what is the best approach to setup database and respective forms in salesforce.

Do we have to use default sobject or do we have to create custom object or a combination of  both.
Not sure where to start
sum__c field in contact and total_sum__c field in account
for all the contact fr a particular account 
i want the total sum to be displayed in total_sum__c field
like in 1 contact sum__c field has 10
in other contact sum__c field is 20
so total_sum__c should be 30

i dont want to use aggregate funt and roll up summary?
any idea


trigger sum_Total_Sum on Contact (after insert,after update ,after delete)
{
    set<id> conAccId = new set<id>();
   
              if(trigger.isInsert || trigger.isUpdate)
              {
                  for(contact c : trigger.new)
                    {
                          conAccId.add(c.AccountId);
                     
                    }
               }
      
      
            if(trigger.isDelete)
            {
               for(contact c: trigger.old)
                {
                conAccId.add(c.AccountId);
                }
            }
           
       
      List<account> accountToUpdate = new List<account>();
     
 
       for( account ac :[select id,(select id, Sum__c from contacts ) from account  where id IN : conAccId ])
        {
                      
                      
                     ac.Total_Sum__c =ac.Total_Sum__c + c.Sum__c;
                   
                    accountToUpdate.add(ac);
              
        }
     update accountToUpdate;
    
  }
I want to create a custom field in the contacts page. I was wondering if its possible to set the field values as some data aquired by an API. Something like calling a javascript to get the values. I wasn't quite able to find anything like that when trying to create a new custom field.