• Fitzgerald Anukam
  • NEWBIE
  • 20 Points
  • Member since 2016


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
Hi, I have created a VF page for my custom object with a search field included. The search field works fine but when I enters a null character or 1 character, I expects it to show me an error message in the VF page, ideally in .INFO style but it is showing me an expression error on another page.

User-added image

I am very new to VisualForce and Apex and would appreciate some help. I know I am miissing something out but can't seem to figure it out.

Apex Class:
public class QFSearchController {

    String searchText;
    List<Quality_Feedback__c> results;
    

    public String getSearchText() {
        return searchText;
    }

    public void setSearchText(String s) {
        searchText = s;
    }
    
    public List<Quality_Feedback__c> getResults() {
        return results;
    }

    public PageReference doSearch() {
    

if(searchText==null || searchText=='')
 { 
 Apexpages.addMessage(new Apexpages.Message(ApexPages.severity.INFO, 'Search term must be longer than one character:')); 
 }
 
 else if (searchText.length()<2)
 {
 Apexpages.addMessage(new Apexpages.Message(ApexPages.severity.INFO, 'Input box must contain at least two characters')); 
 }
 results = (List<Quality_Feedback__c>)[FIND :searchText RETURNING Quality_Feedback__c(Name, Type_of_Feedback__c,    
Feedback_For__c,   Reviewed_By__c, Review_Status__c, Incident__c)][0];
        return null;
    }
}

VisualForce Page:
<apex:page controller="QFSearchController"> 
 <apex:ListViews type="Quality_Feedback__c" />
   <apex:form >   
      <apex:pageBlock mode="edit" id="block">
         <apex:pageBlockSection >
            <apex:pageBlockSectionItem >
               <apex:outputLabel for="searchText">Search Text</apex:outputLabel>
               <apex:panelGroup >
                  <apex:inputText id="searchText" value="{!searchText}"/>
                  <apex:commandButton value="Go!" action="{!doSearch}" 
                                      rerender="block" status="status"/>
               </apex:panelGroup>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:actionStatus id="status" startText="requesting..."/>
        <apex:pageBlockSection title="Results" id="results" columns="1">
           <apex:pageBlockTable value="{!results}" var="l" 
                               rendered="{!NOT(ISNULL(results))}">
              <apex:column value="{!l.name}"/>
              <apex:column value="{!l.Type_of_Feedback__c}"/>
              <apex:column value="{!l.Feedback_For__c}"/>
              <apex:column value="{!l.Reviewed_By__c}"/>
              <apex:column value="{!l.Review_Status__c}"/>
              <apex:column value="{!l.Incident__c}"/>
           </apex:pageBlockTable>
        </apex:pageBlockSection>
      </apex:pageBlock>
       <apex:pageMessages />
   </apex:form>
 
</apex:page>

Thanks in advance.
Hi,

  I want below formula not to run when system administrator logins but this is firing even when system admininstrator logins.  Please suggest me how to fix below issue.
AND ( 
NOT($Profile.Name <> "System Administrator"),
ISBLANK(TEXT(Partner_Information__c)), 
OR(
ISPICKVAL(StageName , "1 - Closed Won"),
ISPICKVAL(StageName , "2 - Contracts"),
ISPICKVAL(StageName , "3 - Proposal")
)
)
Thanks
Sudhir
 
Hi, I have created a VF page for my custom object with a search field included. The search field works fine but when I enters a null character or 1 character, I expects it to show me an error message in the VF page, ideally in .INFO style but it is showing me an expression error on another page.

User-added image

I am very new to VisualForce and Apex and would appreciate some help. I know I am miissing something out but can't seem to figure it out.

Apex Class:
public class QFSearchController {

    String searchText;
    List<Quality_Feedback__c> results;
    

    public String getSearchText() {
        return searchText;
    }

    public void setSearchText(String s) {
        searchText = s;
    }
    
    public List<Quality_Feedback__c> getResults() {
        return results;
    }

    public PageReference doSearch() {
    

if(searchText==null || searchText=='')
 { 
 Apexpages.addMessage(new Apexpages.Message(ApexPages.severity.INFO, 'Search term must be longer than one character:')); 
 }
 
 else if (searchText.length()<2)
 {
 Apexpages.addMessage(new Apexpages.Message(ApexPages.severity.INFO, 'Input box must contain at least two characters')); 
 }
 results = (List<Quality_Feedback__c>)[FIND :searchText RETURNING Quality_Feedback__c(Name, Type_of_Feedback__c,    
Feedback_For__c,   Reviewed_By__c, Review_Status__c, Incident__c)][0];
        return null;
    }
}

VisualForce Page:
<apex:page controller="QFSearchController"> 
 <apex:ListViews type="Quality_Feedback__c" />
   <apex:form >   
      <apex:pageBlock mode="edit" id="block">
         <apex:pageBlockSection >
            <apex:pageBlockSectionItem >
               <apex:outputLabel for="searchText">Search Text</apex:outputLabel>
               <apex:panelGroup >
                  <apex:inputText id="searchText" value="{!searchText}"/>
                  <apex:commandButton value="Go!" action="{!doSearch}" 
                                      rerender="block" status="status"/>
               </apex:panelGroup>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:actionStatus id="status" startText="requesting..."/>
        <apex:pageBlockSection title="Results" id="results" columns="1">
           <apex:pageBlockTable value="{!results}" var="l" 
                               rendered="{!NOT(ISNULL(results))}">
              <apex:column value="{!l.name}"/>
              <apex:column value="{!l.Type_of_Feedback__c}"/>
              <apex:column value="{!l.Feedback_For__c}"/>
              <apex:column value="{!l.Reviewed_By__c}"/>
              <apex:column value="{!l.Review_Status__c}"/>
              <apex:column value="{!l.Incident__c}"/>
           </apex:pageBlockTable>
        </apex:pageBlockSection>
      </apex:pageBlock>
       <apex:pageMessages />
   </apex:form>
 
</apex:page>

Thanks in advance.
We have a visualforce page for building opportunity products.
There's a button - "Save & Exit", which calls the controller method to save the selected products and returns the pagereference - "new PageReference('/' + ApexPages.currentPage().getParameters().get('Id'));"
Basically, it tells the page to go back to the opportunity page. This works perfectly in the classic view. But in lightning, sometimes, after clicking the button, the page goes to a blank page with only lightning sidebar & top bar rather than back to the opportunity page.
Can anyone provide any thoughts on this issue?
Here is the trailhead Challege:
To pass this challenge, create a new list view which only shows contacts belonging to you that have been created or modified in the last week.The list view must be named 'My Recent Contacts'.
The list view should only be visible to you.
The list view must show contacts belonging to you that have been created or modified in the last week.

Solution Created on my Salesforce Dev account:
User-added image

Error Encountered:
User-added image

Could someone suggest why trailhead is not able to recogonize the list view on my account?

Many thanks
Senthil