• sfdc dev 2317
  • NEWBIE
  • 15 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
Hello there,
I can see in related list there 2 Approvals on quote object. But how do I check in formula field (in quote object), that Approvals is not equal to null. 
User-added image
Hello,
I have VF page, build to perform search on Case object. I am already performing search based on Case Status, Case Number.
I want to add one more search based on field "Product". Product(Master) is a lookup field on Case(Child). 
So, how do I create a Product lookup field (with magnifying symbol besides it) and Add that its values in soql and perform a search? 
Any help is appriciated !!
Thanks in advance.

Visualforce page:
apex:page controller="VF_CaseSearch" action="{!searchCase}" tabStyle="Case" sidebar="false">
    <apex:form >
        <apex:pageBlock title="Case Details To Search">
            <apex:pageblockSection >
                <apex:inputText value="{!cas.CaseNumber}" label="Search Case Number"/>
                <apex:inputCheckbox value="{!cas.Status_Closed__c }" label="Status Closed?"/>
                <apex:inputText value="{!cas.Product__c}" label="Search Product"/>
            </apex:pageblockSection>

 <!---Search Button--> 
            <apex:pageblockButtons location="bottom">
                <apex:commandButton value="Search" action="{!searchCase}"/>
            </apex:pageblockButtons>
       </apex:pageBlock>
 <apex:pageBlock>
  <apex:pageBlockTable value="{!caseList}" var="c"> 
                <apex:column value="{!c.CaseNumber}" headerValue="Case Number"/> 
               <apex:column value="{!c.Status}" headerValue="Status"/>
                <apex:column value="{!c.Product__c}" headerValue="Product"/>
            </apex:pageBlockTable>
      </apex:pageBlock>
   </apex:form>
</apex:page>

Custom Controller:
public with sharing class VF_CaseSearch {

  public Case cas{get;set;}
  public List<Case> caseList {get;set;}
  List<string> conditions = new List<string>();
  
    public VFC_CasesMultipleSearch(){
      cas = new Case();
  }
  
  public void searchCase(){
      if(caseList !=null && caseList.size()>0){
          caseList=null;
      }
      searchCases ();
      conditions.clear();
  }
  
  
  public Void searchCases(){
      if(caseList != null && !caseList.isEmpty()){
          caseList.clear();
      }

      //create a dynamic query for filter results
      String strQuery ='SELECT Id, CaseNumber, Product__c, Status, Status_Closed__c FROM Case';
    
      if(cas.CaseNumber !=null && cas.CaseNumber !=''){
          conditions.add('CaseNumber Like\'%' +cas.CaseNumber +'%\' ');
      }
      
       if(cas.Product__c !=null && cas.Product__c !=''){
          conditions.add('Product__r.Name Like\'%' +cas.Product__c +'%\' ');
           system.debug('Product Name' + cas.Product__c);
      }
            
       if(cas.Status_Closed__c){
          conditions.add('Status_Closed__c='+cas.Status_Closed__c);
       }else{
           conditions.add('Status_Closed__c='+ cas.Status_Closed__c);
       }
      
      if (conditions.size() > 0) {
          strQuery += '  WHERE  ' + conditions[0];
          for (Integer i = 1; i < conditions.size(); i++)
              strQuery += '  AND  ' + conditions[i];
      }
      
      caseList = Database.query(strQuery);

  }
}



 
With regrads to my previous question (https://developer.salesforce.com/forums/ForumsMain?id=9062I000000QzvvQAC), I am trying to save records on one of the pageblockTable column Case Review Notes (Case_Comments_On_VFReport__c). 
It does save in a variable and when I hit on save button, I can see value only on UI. But nothing gets updated in database. Even after quering in Devconsole I dont see any updates on this field.  

Can you guys please help me out, where I am doing wrong and what should be included in code? 

Here is VF page:
<apex:page controller="VF_CaseSearch" action="{!searchCase}" tabStyle="Case" sidebar="false">
    <apex:form >
        <apex:pageBlock>

            <apex:pageblockSection >
                <apex:inputText value="{!cas.CaseNumber}" label="Search Case Number"/>
            </apex:pageblockSection>
            
            <!---Search Button--> 
            <apex:pageblockButtons location="bottom">
                <apex:commandButton value="Search" action="{!searchCase}"/>
            </apex:pageblockButtons>
            </apex:pageBlock>
 
        <apex:pageBlock title="Case Details" id="details" rendered="{! IF( caseList != null && caseList.size >0, true, false)}" mode="edit">
            <apex:pageBlockTable value="{!caseList}" var="c">  
                <apex:column value="{!c.CaseNumber}" headerValue="Case Number"/>
                <apex:column value="{!c.CreatedDate}" headerValue="Created Date"/> 
                <apex:column value="{!c.Status}" headerValue="Status"/>
                <apex:column value="{!c.Severity__c}" headerValue="Priority"/>
                <apex:column headerValue="Case Review Notes">
                    <apex:inputField value="{!c.Case_Comments_On_VFReport__c}" />
                </apex:column>
            </apex:pageBlockTable>
           <apex:inlineEditSupport />
            
                    <!---Save Button -->
                    <apex:pageBlockButtons html-align="left" location="top">
                          <apex:commandButton value="Save" action="{!save}" />
                    </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Custom Controller:
public with sharing class VF_CaseSearch {

  public Case cas{get;set;}
  public List<Case> caseList {get;set;}
  List<string> conditions = new List<string>();
  
    public VF_CaseSearch(){
      cas = new Case();
  }
  
  public void searchCase(){
      if(caseList !=null && caseList.size()>0){
          caseList=null;
      }
      searchCases();
      conditions.clear();
  }
  
  
  public Void searchCases(){
      if(caseList != null && !caseList.isEmpty()){
          caseList.clear();
      }

      //create a dynamic query for filter results
      String strQuery ='SELECT Id, CaseNumber, CreatedDate, Status, Severity__c, Case_Comments_On_VFReport__c, FROM Case';
    
      if(cas.CaseNumber !=null && cas.CaseNumber !=''){
          conditions.add('CaseNumber Like\'%' +cas.CaseNumber +'%\' ');
      }
           
      if (conditions.size() > 0) {
          strQuery += '  WHERE  ' + conditions[0];
          for (Integer i = 1; i < conditions.size(); i++)
              strQuery += '  AND  ' + conditions[i];
      }
      
      caseList = Database.query(strQuery);
  }
    
     // Save button
     public PageReference save(){
        try{
            Database.update(caseList);
            system.debug('caseList'+ caseList);
            return ApexPages.CurrentPage();
        }
        catch(DMLException e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,e.getMessage()));
        }
        return null;
    }
}


 
 Below code was intended to do dynamic search on Case object and display results in pageblocktable. Now, I have added inlineEditSupport and save function to it. As I want to save values in inputField "Case Review Notes" field (Case_Comments_On_VFReport__c). When I click on Save button, it does save value, but only on UI. When I refresh page, value is gone. Also when I tried to query Case_Comments_On_VFReport__c in devconsole I don't see any update on this field.
I am just trying to get hands on Visualforce page and Apex. Can you guys please help me here with code?

Visualforce Page:
<apex:page controller="VF_CaseSearch" action="{!searchCase}" tabStyle="Case" sidebar="false">
    <apex:form >
        <apex:pageBlock>

            <apex:pageblockSection >
                <apex:inputText value="{!cas.CaseNumber}" label="Search Case Number"/>
            </apex:pageblockSection>
            
            <!---Search Button--> 
            <apex:pageblockButtons location="bottom">
                <apex:commandButton value="Search" action="{!searchCase}"/>
            </apex:pageblockButtons>
            </apex:pageBlock>
 
        <apex:pageBlock title="Case Details" id="details" rendered="{! IF( caseList != null && caseList.size >0, true, false)}" mode="edit">
            <apex:pageBlockTable value="{!caseList}" var="c">  
                <apex:column value="{!c.CaseNumber}" headerValue="Case Number"/>
                <apex:column value="{!c.CreatedDate}" headerValue="Created Date"/> 
                <apex:column value="{!c.Status}" headerValue="Status"/>
                <apex:column value="{!c.Severity__c}" headerValue="Priority"/>
                <apex:column headerValue="Case Review Notes">
                    <apex:inputField value="{!c.Case_Comments_On_VFReport__c}" />
                </apex:column>
            </apex:pageBlockTable>
           <apex:inlineEditSupport />
            
                    <!---Save Button -->
                    <apex:pageBlockButtons html-align="left" location="top">
                          <apex:commandButton value="Save" action="{!save}" />
                    </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Custom Controller:
public with sharing class VF_CaseSearch {

  public Case cas{get;set;}
  public List<Case> caseList {get;set;}
  List<string> conditions = new List<string>();
  
    public VF_CaseSearch(){
      cas = new Case();
  }
  
  public void searchCase(){
      if(caseList !=null && caseList.size()>0){
          caseList=null;
      }
      searchCase**s** ();
      conditions.clear();
  }
  
  
  public Void searchCase**s**(){
      if(caseList != null && !caseList.isEmpty()){
          caseList.clear();
      }

      //create a dynamic query for filter results
      String strQuery ='SELECT Id, CaseNumber, CreatedDate, Status, Severity__c, Case_Comments_On_VFReport__c, FROM Case';
    
      if(cas.SAC__c !=null && cas.SAC__c !=''){
          conditions.add('SAC__c Like\'%' +cas.SAC__c +'%\' ');
      }
           
      if (conditions.size() > 0) {
          strQuery += '  WHERE  ' + conditions[0];
          for (Integer i = 1; i < conditions.size(); i++)
              strQuery += '  AND  ' + conditions[i];
      }
      
      caseList = Database.query(strQuery);
  }
    
     // Save button
     public PageReference save(){
        try{
            Database.update(caseList);
            system.debug('caseList'+ caseList);
            return ApexPages.CurrentPage();
        }
        catch(DMLException e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,e.getMessage()));
        }
        return null;
    }
}


 
Hello there,
I can see in related list there 2 Approvals on quote object. But how do I check in formula field (in quote object), that Approvals is not equal to null. 
User-added image
Hello,
I have VF page, build to perform search on Case object. I am already performing search based on Case Status, Case Number.
I want to add one more search based on field "Product". Product(Master) is a lookup field on Case(Child). 
So, how do I create a Product lookup field (with magnifying symbol besides it) and Add that its values in soql and perform a search? 
Any help is appriciated !!
Thanks in advance.

Visualforce page:
apex:page controller="VF_CaseSearch" action="{!searchCase}" tabStyle="Case" sidebar="false">
    <apex:form >
        <apex:pageBlock title="Case Details To Search">
            <apex:pageblockSection >
                <apex:inputText value="{!cas.CaseNumber}" label="Search Case Number"/>
                <apex:inputCheckbox value="{!cas.Status_Closed__c }" label="Status Closed?"/>
                <apex:inputText value="{!cas.Product__c}" label="Search Product"/>
            </apex:pageblockSection>

 <!---Search Button--> 
            <apex:pageblockButtons location="bottom">
                <apex:commandButton value="Search" action="{!searchCase}"/>
            </apex:pageblockButtons>
       </apex:pageBlock>
 <apex:pageBlock>
  <apex:pageBlockTable value="{!caseList}" var="c"> 
                <apex:column value="{!c.CaseNumber}" headerValue="Case Number"/> 
               <apex:column value="{!c.Status}" headerValue="Status"/>
                <apex:column value="{!c.Product__c}" headerValue="Product"/>
            </apex:pageBlockTable>
      </apex:pageBlock>
   </apex:form>
</apex:page>

Custom Controller:
public with sharing class VF_CaseSearch {

  public Case cas{get;set;}
  public List<Case> caseList {get;set;}
  List<string> conditions = new List<string>();
  
    public VFC_CasesMultipleSearch(){
      cas = new Case();
  }
  
  public void searchCase(){
      if(caseList !=null && caseList.size()>0){
          caseList=null;
      }
      searchCases ();
      conditions.clear();
  }
  
  
  public Void searchCases(){
      if(caseList != null && !caseList.isEmpty()){
          caseList.clear();
      }

      //create a dynamic query for filter results
      String strQuery ='SELECT Id, CaseNumber, Product__c, Status, Status_Closed__c FROM Case';
    
      if(cas.CaseNumber !=null && cas.CaseNumber !=''){
          conditions.add('CaseNumber Like\'%' +cas.CaseNumber +'%\' ');
      }
      
       if(cas.Product__c !=null && cas.Product__c !=''){
          conditions.add('Product__r.Name Like\'%' +cas.Product__c +'%\' ');
           system.debug('Product Name' + cas.Product__c);
      }
            
       if(cas.Status_Closed__c){
          conditions.add('Status_Closed__c='+cas.Status_Closed__c);
       }else{
           conditions.add('Status_Closed__c='+ cas.Status_Closed__c);
       }
      
      if (conditions.size() > 0) {
          strQuery += '  WHERE  ' + conditions[0];
          for (Integer i = 1; i < conditions.size(); i++)
              strQuery += '  AND  ' + conditions[i];
      }
      
      caseList = Database.query(strQuery);

  }
}



 
With regrads to my previous question (https://developer.salesforce.com/forums/ForumsMain?id=9062I000000QzvvQAC), I am trying to save records on one of the pageblockTable column Case Review Notes (Case_Comments_On_VFReport__c). 
It does save in a variable and when I hit on save button, I can see value only on UI. But nothing gets updated in database. Even after quering in Devconsole I dont see any updates on this field.  

Can you guys please help me out, where I am doing wrong and what should be included in code? 

Here is VF page:
<apex:page controller="VF_CaseSearch" action="{!searchCase}" tabStyle="Case" sidebar="false">
    <apex:form >
        <apex:pageBlock>

            <apex:pageblockSection >
                <apex:inputText value="{!cas.CaseNumber}" label="Search Case Number"/>
            </apex:pageblockSection>
            
            <!---Search Button--> 
            <apex:pageblockButtons location="bottom">
                <apex:commandButton value="Search" action="{!searchCase}"/>
            </apex:pageblockButtons>
            </apex:pageBlock>
 
        <apex:pageBlock title="Case Details" id="details" rendered="{! IF( caseList != null && caseList.size >0, true, false)}" mode="edit">
            <apex:pageBlockTable value="{!caseList}" var="c">  
                <apex:column value="{!c.CaseNumber}" headerValue="Case Number"/>
                <apex:column value="{!c.CreatedDate}" headerValue="Created Date"/> 
                <apex:column value="{!c.Status}" headerValue="Status"/>
                <apex:column value="{!c.Severity__c}" headerValue="Priority"/>
                <apex:column headerValue="Case Review Notes">
                    <apex:inputField value="{!c.Case_Comments_On_VFReport__c}" />
                </apex:column>
            </apex:pageBlockTable>
           <apex:inlineEditSupport />
            
                    <!---Save Button -->
                    <apex:pageBlockButtons html-align="left" location="top">
                          <apex:commandButton value="Save" action="{!save}" />
                    </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Custom Controller:
public with sharing class VF_CaseSearch {

  public Case cas{get;set;}
  public List<Case> caseList {get;set;}
  List<string> conditions = new List<string>();
  
    public VF_CaseSearch(){
      cas = new Case();
  }
  
  public void searchCase(){
      if(caseList !=null && caseList.size()>0){
          caseList=null;
      }
      searchCases();
      conditions.clear();
  }
  
  
  public Void searchCases(){
      if(caseList != null && !caseList.isEmpty()){
          caseList.clear();
      }

      //create a dynamic query for filter results
      String strQuery ='SELECT Id, CaseNumber, CreatedDate, Status, Severity__c, Case_Comments_On_VFReport__c, FROM Case';
    
      if(cas.CaseNumber !=null && cas.CaseNumber !=''){
          conditions.add('CaseNumber Like\'%' +cas.CaseNumber +'%\' ');
      }
           
      if (conditions.size() > 0) {
          strQuery += '  WHERE  ' + conditions[0];
          for (Integer i = 1; i < conditions.size(); i++)
              strQuery += '  AND  ' + conditions[i];
      }
      
      caseList = Database.query(strQuery);
  }
    
     // Save button
     public PageReference save(){
        try{
            Database.update(caseList);
            system.debug('caseList'+ caseList);
            return ApexPages.CurrentPage();
        }
        catch(DMLException e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,e.getMessage()));
        }
        return null;
    }
}


 
 Below code was intended to do dynamic search on Case object and display results in pageblocktable. Now, I have added inlineEditSupport and save function to it. As I want to save values in inputField "Case Review Notes" field (Case_Comments_On_VFReport__c). When I click on Save button, it does save value, but only on UI. When I refresh page, value is gone. Also when I tried to query Case_Comments_On_VFReport__c in devconsole I don't see any update on this field.
I am just trying to get hands on Visualforce page and Apex. Can you guys please help me here with code?

Visualforce Page:
<apex:page controller="VF_CaseSearch" action="{!searchCase}" tabStyle="Case" sidebar="false">
    <apex:form >
        <apex:pageBlock>

            <apex:pageblockSection >
                <apex:inputText value="{!cas.CaseNumber}" label="Search Case Number"/>
            </apex:pageblockSection>
            
            <!---Search Button--> 
            <apex:pageblockButtons location="bottom">
                <apex:commandButton value="Search" action="{!searchCase}"/>
            </apex:pageblockButtons>
            </apex:pageBlock>
 
        <apex:pageBlock title="Case Details" id="details" rendered="{! IF( caseList != null && caseList.size >0, true, false)}" mode="edit">
            <apex:pageBlockTable value="{!caseList}" var="c">  
                <apex:column value="{!c.CaseNumber}" headerValue="Case Number"/>
                <apex:column value="{!c.CreatedDate}" headerValue="Created Date"/> 
                <apex:column value="{!c.Status}" headerValue="Status"/>
                <apex:column value="{!c.Severity__c}" headerValue="Priority"/>
                <apex:column headerValue="Case Review Notes">
                    <apex:inputField value="{!c.Case_Comments_On_VFReport__c}" />
                </apex:column>
            </apex:pageBlockTable>
           <apex:inlineEditSupport />
            
                    <!---Save Button -->
                    <apex:pageBlockButtons html-align="left" location="top">
                          <apex:commandButton value="Save" action="{!save}" />
                    </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Custom Controller:
public with sharing class VF_CaseSearch {

  public Case cas{get;set;}
  public List<Case> caseList {get;set;}
  List<string> conditions = new List<string>();
  
    public VF_CaseSearch(){
      cas = new Case();
  }
  
  public void searchCase(){
      if(caseList !=null && caseList.size()>0){
          caseList=null;
      }
      searchCase**s** ();
      conditions.clear();
  }
  
  
  public Void searchCase**s**(){
      if(caseList != null && !caseList.isEmpty()){
          caseList.clear();
      }

      //create a dynamic query for filter results
      String strQuery ='SELECT Id, CaseNumber, CreatedDate, Status, Severity__c, Case_Comments_On_VFReport__c, FROM Case';
    
      if(cas.SAC__c !=null && cas.SAC__c !=''){
          conditions.add('SAC__c Like\'%' +cas.SAC__c +'%\' ');
      }
           
      if (conditions.size() > 0) {
          strQuery += '  WHERE  ' + conditions[0];
          for (Integer i = 1; i < conditions.size(); i++)
              strQuery += '  AND  ' + conditions[i];
      }
      
      caseList = Database.query(strQuery);
  }
    
     // Save button
     public PageReference save(){
        try{
            Database.update(caseList);
            system.debug('caseList'+ caseList);
            return ApexPages.CurrentPage();
        }
        catch(DMLException e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,e.getMessage()));
        }
        return null;
    }
}