• Vidya Rani
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 6
    Replies
Need HELP !
Created an Account search page with few fields. Result should only show records which satisfies values entered by users. Currently my result page is showing all the records as blank fields not filled by users is also getting queried. How to query for fields which are only entered by users and skip blank ones?

My Controller:
public class Searchaccts {
  public List<Account> MAccounts{ get; set; }
  public String name { get; set; }
  public String Active { get; set; }
  public String Priority { get; set; }
  public String UpOpp { get; set; }
  public Searchaccts(ApexPages.StandardController controller) {
    
    }


    
    public void Searchaccts() {
   
    MAccounts= [select Id
                          ,Name
                          ,Active__c,CustomerPriority__c,UpsellOpportunity__c
                    from Account
                    where Name = :name
                    OR Active__c= :Active OR CustomerPriority__c = :Priority OR UpsellOpportunity__c = :UpOpp]; 
         
         System.debug('SearchListt ' + MAccounts +'!');
             }
}
My Page:

<apex:page StandardController="Account" extensions="Searchaccts" sidebar="true" id="newpage">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
  <!-- Begin Default Content REMOVE THIS 
<apex:image value="http://bit.ly/17iLknp" styleClass="logo" /> -->
<p style="font-size:30px">This is a SEARCH page</p>
        <apex:form >
        <apex:pageblock > 
       <apex:pageBlockSection columns="1" showHeader="true" title="Search Your Account" id="account-Search">
       <apex:pageBlockSectionItem labelTitle="Choose Account Type" >
             <!-- Person Account / Business Account :</h6> &nbsp;&nbsp; -->
              <label> HCO/HCP: </label><apex:selectList id="ChooseAccount" size="1" required="true">   
                <apex:selectOption itemValue="None" itemLabel="--None--"/>              
                <apex:selectOption itemValue="HCP" itemLabel="Person Account"/>
                <apex:selectOption itemValue="HCO" itemLabel="Business Account"/>
                <apex:actionSupport event="onchange" rerender="newpage"/>
                </apex:selectList>                 
               </apex:pageBlockSectionItem> <br/>
        <apex:inputField value="{!Account.Active__c}" id="Active" required="false"/> <br/> 
        <apex:inputField value="{!Account.Name}" id="Name" required="false" /><br/> 
        <apex:inputField value="{!Account.CustomerPriority__c}" id="Priority" required="false"/><br/> 
        <apex:inputField value="{!Account.UpsellOpportunity__c}" id="UpOpp" required="false" /><br/>
        <apex:commandButton action="{!Searchaccts}" value="Search" id="theButton"/>
        </apex:pageBlockSection>
        </apex:pageblock>
            </apex:form>
             <apex:pageBlock > 
             <apex:PageBlockSection >
 <apex:pageBlockTable value="{!MAccounts}" var="c">
                    <apex:column >
                        <apex:facet name="header">Name</apex:facet>
                        {!c.Name}
                    </apex:column>

                    <apex:column >
                        <apex:facet name="header">Active</apex:facet>
                        {!c.Active__c}
                    </apex:column>
               
                </apex:pageBlockTable>
                </apex:PageBlockSection>
                </apex:pageBlock>
          <script>
        $(document).ready(function(){
            $("[id$=ChooseAccount]").change(function(){
                if(this.value=="HCO"){
                            $("[id$=Active]").prop("disabled",true); 
                            $("[id$=Name]").prop("disabled",false);
                              }
                       else if(this.value=="None"){
                            
                            $("[id$=Name]").prop("disabled",false);
                            $("[id$=Active]").prop("disabled",false);
                            }
                       else{
                            
                            $("[id$=Name]").prop("disabled",true);
                            $("[id$=Active]").prop("disabled",false);
                            }
                           });
                          });
             </script>  
  <!-- End Default Content REMOVE THIS -->
</apex:page>
I have created a webtab which will redirect to simple URL. But its showing blank page when I click on the tab.However, clicking on Shield icon in navigation bar to 'load unsafe script; helps.But this dosen't appear to be good user experience to click on shield icon everytime they navigate to tab. Any other suggestion or settings?
 
In case of record creation,am trying to copy value in field "Next call Notes" from a previous record (created by same user on same Account). Unbale to create new record saying : Record is read-only: Trigger.CopyCallNotes: line 26, column 1
Below is code piece. Any help will bereally helpful.

trigger CopyCallNotes on Call__c (after insert, after update) {

public String CurrAcc;
public Id CurrCreatedBy;


 for(Call__c c: Trigger.new){
        CurrAcc = c.Account__c;
        CurrCreatedBy = c.CreatedById;
        System.debug('CAccount' + c.Account__c);
        System.debug('CCreatedBy' + c.CreatedById);
        System.debug('CName' + c.Name);
        System.debug('CId' + c.Id);
                      } 

List<Call__c> listaToTrue = new List<Call__c>([select Next_Call_Notes__c from Call__c where Account__c = : CurrAcc and CreatedById = :CurrCreatedBy order by CreatedDate desc LIMIT 2]);
       System.debug('ListSize' + listaToTrue.size());
       System.debug('Listvalue' + listaToTrue.get(1)); 

   String NCN = string.valueOf(listaToTrue.get(1).Next_Call_Notes__c);
   System.debug('NCNvalue' + NCN);
        for(Call__c a: Trigger.new){
         a.Next_Call_Notes__c = NCN;   // line 26
         System.debug('CNCN' + a.Next_Call_Notes__c);
         }                   
                      

}
I am trying to display list of Accounts using Standard controller and allow inline edit of records displayed. The Save button I have added is not working/saving the udpate in database. Can someone please help, what m I missing
Do I need to write extension for this?

Code piece:
<apex:page standardController="Account" recordSetVar="Account">  <!-- extensions="myControllerExtension"> -->
    <apex:form >
    <apex:pageBlock title="Account Summary" mode="inlineEdit">
    <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" 
                        hideOnEdit="editButton" event="ondblclick" 
                        changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
                        
                <apex:commandButton action="{!quicksave}" id="saveButton" value="Save" rendered="true"/>
                <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel" rendered="true"/>
  <apex:pageBlockTable value="{! Account}" var="at">
            <apex:column value="{! at.Name }"/>
            <apex:column value="{! at.Phone}"/>
            <apex:column value="{! at.Industry}"/>
            <apex:column value="{! at.AnnualRevenue }"/>
            <apex:column value="{! at.Id }"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
     </apex:form>
</apex:page>
I am trying to use multiselect picklist on vf page and show results based on selected values via button click. Getting Error :
" Visualforce Error
System.NullPointerException: Attempt to de-reference a null object 
External entry point "


Any suggestions will really help. Thanks in advance.

Code Piece:
<apex:page controller="SinglepicklistforMyBook" action="{!autoRun}" sidebar="false">

    <apex:form >
     <table align="center" cellpadding="15" > 
    <td>Select Property Type :-</td>
         <td><apex:selectList size="4" value="{!SelectValue}" multiselect="true">
            <apex:selectOptions value="{!statusOptions}"/>       

        </apex:selectList></td>        
       <tr> <td>List of Selected Values For Books of Type:</td> 
  <td><apex:outputText label="You have selected:" value="{!SelectValue}" /> </td> </tr>
          <div align="center" draggable="false" > 
            <apex:commandButton style="float:centre" value="Show Result" onclick="{!ShowResult}"/>
            <apex:actionSupport reRender="refresh" event="onkeyup" />
            </div>
                 <apex:pageBlock >
   <apex:pageblockTable align="center" cellpadding="15" value="{!ShowResult}" var="O" title="List of Selected Books">
       <apex:column value="{!O.Name}"/>
       <apex:column value="{!O.Status_Book__c}"/>
       </apex:pageblockTable> 
  </apex:pageBlock>   
        </table>
    </apex:form>
</apex:page>
*************************
Controller
*************************
public with sharing class SinglepicklistforMyBook {

public List<SelectOption> statusOptions { get;set; }
public List<String> selectValue {get;set;} //for multiselect
     
    //    public string selectValue { get;set; }  //in case multiselect =false
 List<Book__c> showresult;
    public List<Book__c> getShowResult() {
 
      //showresult=  [Select Name, Status_Book__c from Book__c where Status_Book__c = :selectValue ]; // for multiselect = false
        showresult=  [Select Name, Status_Book__c from Book__c where Status_Book__c IN :selectValue]; //for multiselect
        return showresult;
    }

public void autoRun()

{

    Schema.DescribeFieldResult statusFieldDescription = Book__c.Status_Book__c.getDescribe();

    statusOptions = new list<SelectOption>();     

    for (Schema.Picklistentry picklistEntry : statusFieldDescription.getPicklistValues())

    {

        statusOptions.add(new SelectOption(pickListEntry.getValue(),pickListEntry.getLabel()));

    }

}

}
In case of record creation,am trying to copy value in field "Next call Notes" from a previous record (created by same user on same Account). Unbale to create new record saying : Record is read-only: Trigger.CopyCallNotes: line 26, column 1
Below is code piece. Any help will bereally helpful.

trigger CopyCallNotes on Call__c (after insert, after update) {

public String CurrAcc;
public Id CurrCreatedBy;


 for(Call__c c: Trigger.new){
        CurrAcc = c.Account__c;
        CurrCreatedBy = c.CreatedById;
        System.debug('CAccount' + c.Account__c);
        System.debug('CCreatedBy' + c.CreatedById);
        System.debug('CName' + c.Name);
        System.debug('CId' + c.Id);
                      } 

List<Call__c> listaToTrue = new List<Call__c>([select Next_Call_Notes__c from Call__c where Account__c = : CurrAcc and CreatedById = :CurrCreatedBy order by CreatedDate desc LIMIT 2]);
       System.debug('ListSize' + listaToTrue.size());
       System.debug('Listvalue' + listaToTrue.get(1)); 

   String NCN = string.valueOf(listaToTrue.get(1).Next_Call_Notes__c);
   System.debug('NCNvalue' + NCN);
        for(Call__c a: Trigger.new){
         a.Next_Call_Notes__c = NCN;   // line 26
         System.debug('CNCN' + a.Next_Call_Notes__c);
         }                   
                      

}
I am trying to display list of Accounts using Standard controller and allow inline edit of records displayed. The Save button I have added is not working/saving the udpate in database. Can someone please help, what m I missing
Do I need to write extension for this?

Code piece:
<apex:page standardController="Account" recordSetVar="Account">  <!-- extensions="myControllerExtension"> -->
    <apex:form >
    <apex:pageBlock title="Account Summary" mode="inlineEdit">
    <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" 
                        hideOnEdit="editButton" event="ondblclick" 
                        changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
                        
                <apex:commandButton action="{!quicksave}" id="saveButton" value="Save" rendered="true"/>
                <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel" rendered="true"/>
  <apex:pageBlockTable value="{! Account}" var="at">
            <apex:column value="{! at.Name }"/>
            <apex:column value="{! at.Phone}"/>
            <apex:column value="{! at.Industry}"/>
            <apex:column value="{! at.AnnualRevenue }"/>
            <apex:column value="{! at.Id }"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
     </apex:form>
</apex:page>
I am trying to use multiselect picklist on vf page and show results based on selected values via button click. Getting Error :
" Visualforce Error
System.NullPointerException: Attempt to de-reference a null object 
External entry point "


Any suggestions will really help. Thanks in advance.

Code Piece:
<apex:page controller="SinglepicklistforMyBook" action="{!autoRun}" sidebar="false">

    <apex:form >
     <table align="center" cellpadding="15" > 
    <td>Select Property Type :-</td>
         <td><apex:selectList size="4" value="{!SelectValue}" multiselect="true">
            <apex:selectOptions value="{!statusOptions}"/>       

        </apex:selectList></td>        
       <tr> <td>List of Selected Values For Books of Type:</td> 
  <td><apex:outputText label="You have selected:" value="{!SelectValue}" /> </td> </tr>
          <div align="center" draggable="false" > 
            <apex:commandButton style="float:centre" value="Show Result" onclick="{!ShowResult}"/>
            <apex:actionSupport reRender="refresh" event="onkeyup" />
            </div>
                 <apex:pageBlock >
   <apex:pageblockTable align="center" cellpadding="15" value="{!ShowResult}" var="O" title="List of Selected Books">
       <apex:column value="{!O.Name}"/>
       <apex:column value="{!O.Status_Book__c}"/>
       </apex:pageblockTable> 
  </apex:pageBlock>   
        </table>
    </apex:form>
</apex:page>
*************************
Controller
*************************
public with sharing class SinglepicklistforMyBook {

public List<SelectOption> statusOptions { get;set; }
public List<String> selectValue {get;set;} //for multiselect
     
    //    public string selectValue { get;set; }  //in case multiselect =false
 List<Book__c> showresult;
    public List<Book__c> getShowResult() {
 
      //showresult=  [Select Name, Status_Book__c from Book__c where Status_Book__c = :selectValue ]; // for multiselect = false
        showresult=  [Select Name, Status_Book__c from Book__c where Status_Book__c IN :selectValue]; //for multiselect
        return showresult;
    }

public void autoRun()

{

    Schema.DescribeFieldResult statusFieldDescription = Book__c.Status_Book__c.getDescribe();

    statusOptions = new list<SelectOption>();     

    for (Schema.Picklistentry picklistEntry : statusFieldDescription.getPicklistValues())

    {

        statusOptions.add(new SelectOption(pickListEntry.getValue(),pickListEntry.getLabel()));

    }

}

}
Hi, this is related to my earlier post here

I have a fairly large test method that gives me 90% test coverage in sandbox with no problems, but then when I try to migrate it to production, I’m suddenly getting an external entry point error on the last line. I talked to my co-worker and she says it’s because there is some inconsistency between sandbox and production, but I can’t seem to figure out how to fix it. I checked all the validation rules and things like that and can’t find any inconsistencies.

Has anyone come across this before? When something works well in sandbox but then you have this sort of trouble getting it into production?
  • March 29, 2010
  • Like
  • 0