• Eswar Prasad@Sfdc11
  • NEWBIE
  • 121 Points
  • Member since 2015

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 65
    Replies
Hi Team,
             I created a  dynamic search controller for search dynamically in visualforce page . How to write test class for this type controller.

This is my controller code.Please help me how to write test class for this controller.
public with sharing class ContactSearchController {

  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of contacts to display
  public List<Contact> contacts {get;set;}

  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }

  // the current field to sort by. defaults to last name
  public String sortField {
    get  { if (sortField == null) {sortField = 'lastName'; } return sortField;  }
    set;
  }

  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
    set;
  }

  // init the controller and display some sample data when the page loads
  public ContactSearchController() {
  contacts= new List<Contact>();
    soql = 'select FirstName, LastName,account.name,LeadSource FROM Contact Where account.Name!=null';
    runQuery();
  }

  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }

  // runs the actual query
  public void runQuery() {

    try {
      contacts = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }

  }

  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {
      
    String FirstName = Apexpages.currentPage().getParameters().get('FirstName');
    String LastName = Apexpages.currentPage().getParameters().get('LastName');
   
    String LeadSource = Apexpages.currentPage().getParameters().get('LeadSource ');
    
    String accountName= Apexpages.currentPage().getParameters().get('accountName');
   
  

    soql = 'select  FirstName,LastName,LeadSource,account.name FROM Contact Where account.Name!=null';
   
    if (FirstName!= null && !FirstName.equals(''))
      soql += ' and FirstName LIKE \''+String.escapeSingleQuotes(FirstName)+'%\'';
    if (LastName!= null && !LastName.equals(''))
      soql += ' and LastName LIKE \''+String.escapeSingleQuotes(LastName)+'%\'';
    if (accountName!= null && !accountName.equals(''))
      soql += ' and account.Name LIKE \''+String.escapeSingleQuotes(accountName)+'%\'';
    if (LeadSource !=null && !LeadSource.equals(''))
      soql += ' and LeadSource LIKE \''+String.escapeSingleQuotes(LeadSource)+'%\'';  
  
    // run the query again
    runQuery();

    return null;
  }
 public List<String> LeadSource{
    get {
      if (LeadSource== null) {
 
        LeadSource= new List<String>();
        Schema.DescribeFieldResult field = Contact.LeadSource.getDescribe();
 
        for (Schema.PicklistEntry b : field.getPicklistValues())
          LeadSource.add(b.getLabel());
 
      }
      return LeadSource;          
    }
    set;
  }
 
}

 
Hi Experts,

Could anyone increase my code coverage please,its very urgent.what ever striped lines are there those lines are not covered

Class:


trigger tRIIO_Subcontractor_Client_updateContract_Scc on SCC_Client__c (after delete, after insert, after update) {

//CH02.End




set<Id> setSCCId = new set<Id>();

set<string> setClientName = new set<string>();

List<SCC__c> lstSCCUpdate = new List<SCC__c>();

//CH02.Start

List<SCC_Client__c > lstSub = new List<SCC_Client__c>();

//CH02.End

if(trigger.isInsert || trigger.isUpdate)

lstSub = trigger.new;

else

lstSub = trigger.old;

//CH02.Start

for(SCC_Client__c objSC : lstSub){

if(objSC.SCC__c != null)

setSCCId.add(objSC.SCC__c);

}

//CH02.End

map<Id,SCC__c> mapSCC = new map<Id,SCC__c>([select id, name, h_Subcontractor_Client_Name__c, Owning_Region__c,

(select id, name, Client_Names__r.Name from Subcontractor_Clients__r where Client_Names__r.Name = 'tRIIO' or Client_Names__r.Name = 'WPD') //CH01 remove - where Client_Names__r.Name = 'tRIIO' )

from SCC__c where Id =: setSCCId]);

map<Id,string> mapClientName = new map<Id,string>(); //CH01

List<SCC_Clients__c> lstClients = ([select id, Name from SCC_Clients__c where Name = 'tRIIO' or Name = 'WPD' ]); //CH01 added WPD condition

for(SCC_Clients__c objClient: lstClients){

setClientName.add(objClient.Id);

mapClientName.put(objClient.Id,objClient.Name); //CH01

}

if(trigger.isInsert || trigger.isUpdate)

//CH02.Start

for(SCC_Client__c objSub : trigger.new){

if(mapSCC.get(objSub.SCC__c).Owning_Region__c == 'Central'){

if(setClientName.Contains(objSub.Client_Names__c)){

SCC__c objSCC = mapSCC.get(objSub.SCC__c);

// system.debug('@@@ h client name: '+objSCC.h_Subcontractor_Client_Name__c);

//system.debug('@@@ Subcon client name: '+objSub.Client_Names__c);

if(objSCC.h_Subcontractor_Client_Name__c == null || objSCC.h_Subcontractor_Client_Name__c == '')

objSCC.h_Subcontractor_Client_Name__c = mapClientName.get(objSub.Client_Names__c); //CH01

else

if(!objSCC.h_Subcontractor_Client_Name__c.Contains(mapClientName.get(objSub.Client_Names__c)))

objSCC.h_Subcontractor_Client_Name__c = objSCC.h_Subcontractor_Client_Name__c + mapClientName.get(objSub.Client_Names__c); //CH01

//objSCC.h_Subcontractor_Client_Name__c = (!objSCC.h_Subcontractor_Client_Name__c.Contains(mapClientName.get(objSub.Client_Names__c))?objSCC.h_Subcontractor_Client_Name__c:'') + mapClientName.get(objSub.Client_Names__c); //CH01

system.debug('### h client name: '+objSCC.h_Subcontractor_Client_Name__c);

lstSCCUpdate.add(objSCC);

}

else if(mapSCC.get(objSub.SCC__c).Subcontractor_Clients__r.isEmpty()){

SCC__c objSCC = mapSCC.get(objSub.SCC__c);

objSCC.h_Subcontractor_Client_Name__c = '';

lstSCCUpdate.add(objSCC);

}

}

//CH02.End

}

if(trigger.isDelete)

//CH02.Start

for(SCC_Client__c objSub : trigger.old){

if(mapSCC.get(objSub.SCC__c).Owning_Region__c == 'Central')

if(mapSCC.get(objSub.SCC__c).Subcontractor_Clients__r.isEmpty()){

SCC__c objSCC = mapSCC.get(objSub.SCC__c);

objSCC.h_Subcontractor_Client_Name__c = '';

lstSCCUpdate.add(objSCC);

}

//CH02.Start

//CH01.start

else{

SCC__c objSCC = mapSCC.get(objSub.SCC__c);

boolean flgWPD = false;

boolean flgtRIIO = false;

//CH02.Start

for(SCC_Client__c obj :mapSCC.get(objSub.SCC__c).Subcontractor_Clients__r ){

if(obj.Client_Names__r.Name == 'WPD')

flgWPD = true;

if(obj.Client_Names__r.Name == 'tRIIO' )

flgtRIIO = true;

}

//CH02.End

if(mapClientName.get(objSub.Client_Names__c) == 'tRIIO' && objSCC.h_Subcontractor_Client_Name__c.contains('WPD')){

if(flgtRIIO)

objSCC.h_Subcontractor_Client_Name__c = 'WPDtRIIO';

else

objSCC.h_Subcontractor_Client_Name__c = 'WPD';

}

else if(mapClientName.get(objSub.Client_Names__c) == 'WPD' && objSCC.h_Subcontractor_Client_Name__c.contains('tRIIO')){

if(flgWPD)

objSCC.h_Subcontractor_Client_Name__c = 'WPDtRIIO';

else

objSCC.h_Subcontractor_Client_Name__c = 'tRIIO';

}

lstSCCUpdate.add(objSCC);

} //CH01.end

}

if(!lstSCCUpdate.isEmpty()){

List<SCC__c> lstSCC = new List<SCC__c>();

Set<SCC__c> setSCC = new Set<SCC__c>();

for(SCC__c obj:lstSCCUpdate){

if(!setSCC.contains(obj)) lstSCC.add(obj);

setSCC.add(obj);

}

//update lstSCCUpdate;

update lstSCC;

}
}

@isTest

private class tRIIO_Subcont_Client_updateCont_Scc_test {

static testMethod void myUnitTest(){

SCC_Clients__c testSclient = new SCC_Clients__c(Name = 'tRIIO', Owning_Region__c = 'Central');

insert testSclient;

SCC_Clients__c testSclient1 = new SCC_Clients__c(Name = 'test scc client', Owning_Region__c = 'Central');

insert testSclient1;

SCC__c testScc = new SCC__c(Name = 'test SCC', Contact_Name__c = 'test Contact name',Location__c = 'test location',

Street__c = 'test street', Town__c = 'test town', Number_of_Employees__c = 'Less than 5 employees',

Area_Covered__c = 'Central', Owning_Region__c = 'Central');

insert testScc;

//CH01.Start

SCC_Client__c testSubClient = new SCC_Client__c(Name = 'test Subcontractor Client',

Client_Names__c = testSclient.Id , SCC__c = testScc.Id);

insert testSubClient;

testSubClient.Client_Names__c = testSclient1.Id;

update testSubClient;

delete testSubClient;

//CH01.End

}

}
 
Hi All,

I am getting NPE error in line no 55. Can anybody help me out in this how to resolve this . 

Apex Class - 

    public with sharing class soption1
    {

        public soption1() {

        }

        SLA__c account;
        SOC__c contact;
        MSA__c opportunity;
            
        public List<MSA__C> records{get;set;}
        public MSA__c objAct{get;set;}
        public List<MSAWrapper> MSAWrapperList {get; set;}
       
        public soption1(ApexPages.StandardController controller) 
        {
            objAct = new MSA__C();
            MSAWrapperList = new List<MSAWrapper>();
        }
        
        public SLA__c getAccount() {
        if(account == null) account = new SLA__c();
        return account;
        }
        
        public SOC__c getContact() {
        if(contact == null) contact = new SOC__c();
        return contact;
       }
        
        public PageReference step1() {
        return Page.newOpptyStep11;
        }
       
        public PageReference step2() {
          return Page.testmulti1;
        }
        
        
        public pagereference search()
        {
            MSAWrapperList.clear();
            records=[Select ID,Name,Coe__c,Dept__c,OpCo__c from MSA__C  where Coe__c=: objAct.Coe__c and Dept__c=: objAct.Dept__c];
            for(MSA__C obj : records)
            {
                MSAWrapperList.add( new MSAWrapper(obj) );
            }
           return null;
        }

        public PageReference processSelected() 
        {
        
          account.Name = contact.Name;  /// errror here
          insert account;
          
            List<MSA__C> selectedMSA = new List<MSA__C>();
            for(MSAWrapper cCon: MSAWrapperList ) 
            {
                if(cCon.selected == true) 
                {
                    selectedMSA.add(cCon.msaObj);
                }
            }
            for(MSA__C msa: selectedMSA) 
            {
                    system.debug(msa);
                    SOC__c so = new SOC__c();
                    so.Name = msa.Name;
                    so.SLA__c = account.id;
                    insert so;
                // Please add your login here
            }
            return null;
            
            
        }
        
        
        public class MSAWrapper 
        {
            public MSA__C msaObj {get; set;}
            public Boolean selected {get; set;}
            public MSAWrapper(MSA__C c) {
                msaObj = c;
                selected = false;
            }
        }
         
    }

Regards
Hi Guyz, Hope you can halp.. I attached 3 small screenshots to Explain my problem..

I have created a Visualforce page, and I need to achieve condition like below.. At first I'm checking the checkbox and it shows Screenshot and Additional screen shot section..
User-added image

and When uncheck I has to show my page like Below screenshot,,
User-added image

But with the knowledge I have in Javascript I could only achieve this :( User-added image

My Code
<apex:page standardController="SME_Coaching__c" extensions="smecoachingcontroller" id="page" >
  <apex:form id="form" >
 
 <!--**Java Script**-->
   <script type="text/javascript">
            function ToggleInput(theId)
            {
                var e = document.getElementById(theId);

                if(e != null)
                {
                    e.disabled = (e.disabled ? false : "disabled");
                }
            }

            window.onload = function () { document.getElementById('{!$Component.textInput}').disabled = "disabled"; }

        </script>
		
  <apex:pageblock id="pb" >
      <apex:pageblockSection > 
         <apex:pageblockSectionItem >
              <apex:actionRegion >
                <apex:inputcheckbox onchange="inputDisplay(this,'{!$Component.id1}')" selected="true"/>
              </apex:actionRegion>
           <apex:outputlabel value="Screenshot"/>
        </apex:pageblockSectionItem> 
          <apex:inputfile id="id1" value="{!myfile.body}" filename="{!myfile.name}" />                                       
        <apex:pageblockSectionitem >
         &nbsp;<apex:outputlabel value="Additional Screenshot (Optional)"/>
         </apex:pageblockSectionitem>
        <apex:pageblockSectionitem >         
          <apex:inputfile id="id1" value="{!myfile.body}" filename="{!myfile.name}" />                                    
        </apex:pageblockSectionitem>
  </apex:pageblockSection>
 </apex:pageblock>
</apex:form>  
</apex:page>

Appreciate your help. Thanks,



 
Hi,

I have been working on approval process....................
I have 3 fields in loan object.....1. asst manager 2. senior manager 3. regional manager 
Based on the managers i need to pull dynamically in approval process for every loan record.
  • October 19, 2015
  • Like
  • 0
How to disable picklist value once it has been chosen in apex page block table.
Hi
I have a requirement to displays records in pageblock based on "OnClick" event on the pageblock button with render attribute,
That mean when ever the pageblock button is clicked records should be displayed within that pageblock, i am failing to acheive this,
help will be appreciated,

Below is my controller and Vf page code for the reference:

Controller:

public with sharing class DisplayQueryList{ 
public List<Account> Records {get; set;}
public DisplayQueryList(){ 
Records = 
[select Name, AccountNumber, CleanStatus from Account where CleanStatus='Pending']; 

}

VF Page:

<apex:page controller="TestDisplayQueryList">
  <apex:form > 
    <apex:pageBlock title="Tabular display with facet"> 
        <apex:pageBlockTable value="{!Records}" var="Record"> 
            <apex:column > 
                <apex:facet name="header">Account Name</apex:facet> 
                <apex:outputText value="{!Record.Name}"/> 
            </apex:column> 
            <apex:column > 
                <apex:facet name="header">Account Number</apex:facet> 
                <apex:outputText value="{!Record.AccountNumber}"/> 
            </apex:column> 
            <apex:column > 
                <apex:facet name="header">Clean Status</apex:facet> 
                <apex:outputText value="{!Record.CleanStatus}"/> 
            </apex:column> 
        </apex:pageBlockTable> 
    </apex:pageBlock> 
    <apex:pageBlock title="Tabular Display without facet">
    <apex:pageBlockTable value="{!records}" var="record">
        
        <apex:column value="{!record.Name}"/>
        <apex:column value="{!record.AccountNumber}"/>
        <apex:column value="{!record.CleanStatus}"/> 
              
      </apex:pageBlockTable>
    </apex:pageBlock>
   </apex:form>     
</apex:page>
Dear Members,
 We have immediate requirement to move the apps by drag and drop in VF page. Planning to implement by using JQuery. If anybody would have implemented similar functionality or any suggestion kindly email me @ snowshadali@gmail.com.

Page 1                                                                                    |                     Page 2
------------------------------------------------------------------------------------------------------------------------------------------
App1                App2              App3              App4

App5                App6              App7              App8

User by using mouse he will move the App8 to App6 position and all the app should be auto adjust.  Same for Page 2 ..Any suggestion or similar functionality if you would have implemented kindly let me know soon..

Thanks in advance..
Nowshad
HI friends,
My Question is can we implement the SaveandNew method in standard controller ?
if Yes,
Then Help me in this scenario..
<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Save and new" action="{!SaveAndNew}"/>
            
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="Account information">
            
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Then it is raising the error like
[Error] Error: Unknown method 'AccountStandardController.SaveAndNew()'
Thanks and regards,

Anji
I am trying to discover how to override the standard style in Salesforce. I am more of a declartive developer. I would like to keep the SF header. I simply want a new skin (white background).
1) Can you tell me how to do this.
2) Provide sample VF code.  
3) Instruct me as to how to include the VF page, to override the standard SF style, so that the style is universal (application wide)..

 I would truly appreciate it.
Hi 

global class batchDeleteEndUser implements Schedulable
{
    
    public static String CRON_EXP = '0 0 12 1 1/3 ? *';
 
    
    global static String scheduleIt() {
        batchDeleteEndUser delbatch = new batchDeleteEndUser();
        return System.schedule('Delete EndUser Batch', CRON_EXP, delbatch);
        } 
    
 
    
    global void execute(SchedulableContext sc) {
        
        Datetime days = system.now().addDays(-365);
        
       List<EndUser__c> objectList = new List<EndUser__c>();
         
        for (EndUser__c EUser: [
            select Id,name
            from EndUser__c
            where Id not in (select End_User__c from Case where status != 'Closed') and ((Time_of_Last_Created_Case__c<= :days and Time_of_Last_Initiated_Chat__c<=:days ) or (Time_of_Last_Created_Case__c=null and Time_of_Last_Initiated_Chat__c<=:days) or (Time_of_Last_Created_Case__c<= :days and Time_of_Last_Initiated_Chat__c=null))
        ]) {
            objectList.add(EUser);
           
        }
       
 
        if (!objectList.isEmpty()) {
           delete objectList;
           system.debug('enduser----'+objectList);
        }
  }  
}


Hi any one write the test class for above class its very urgent please---------------------

Thanks for Advance

Raj
I want get the approvaler id in trigger. after the user submit the records to approval.  Could someone can help me. and i attached my trigger code as below, very apprecaiate if someone can help. thanks a lot!

User-added image

trigger Promo_ItemList_af_Up on Campaign (before update) {
  set<id> set_campId = new set<id>();
  String APIName = '';
  String APIType = 'Checkbox;';
  Map<id,Decimal > Map_setp = new Map<id,Decimal>();
  Map<Id,String>  Map_APIupdate = new Map<Id,String> ();
  Map<Id,Id>  Map_CurrentApprovaler = new Map<Id,Id> ();
  List<Campaign> List_update;
   ID recordTypeId = Schema.SObjectType.Campaign.getRecordTypeInfosByName().get('Internal propose item approval promotion').getRecordTypeId();
   System.debug('Get Record type id========' + recordTypeId);//只适用于record type为Item的 // recordtype name =Internal propose item approval promotion
   for(Campaign cm:trigger.new){
       if(cm.recordtypeId == recordTypeId){
            set_campId.add(cm.id);//把campain 封装到set里面
            Map_setp.put(cm.id, cm.CurrentApprovalStep__c);  //对应的审批步骤和campain做一个绑定,用来判断是否是有新的审批步骤,从而确定是否需要暴露新的字段给用户操作
        }
   }
   //下面获取需要暴露的字段API名字
   if(set_campId.size()>0){  
        integer currentStep =0;  
       for(ProcessInstance pi:[Select p.TargetObjectId, p.Status, p.Id, (Select Id, StepStatus,OriginalActorId, ActorId,Actor.UserRole.Name From Steps) step From ProcessInstance p where TargetObjectId =:set_campId and Status = 'Pending']){
          currentStep= pi.Steps.size();
           
           String Label = pi.Steps[currentStep -1].Actor.UserRole.Name;
           //System.debug('GET actor name Label======' +Label );
           // System.debug('pi.Steps ========= ========= ===== ======= ===== ======= ===== ======= ===== === ===== ======='+ pi.Steps.size() + '===currentStep======'+currentStep);
         if(Map_setp.get(pi.TargetObjectId) != currentStep){ //当有新的step的时候才做更新,如果是相等的情况下,则跳过。
              APIName = PromoUtils.TransferLabelToAPI(Label,'Promotion_Account_List__c');//调用公共方法转换label为API名字
             // System.debug('APIName ===== ===== ===== ===APIName== ===== ===== ======='+ APIName);
              Map_APIupdate.put(pi.TargetObjectId,APIName);//封装成map,然后再查询出campain的字段,并更新campain字段
              Map_CurrentApprovaler.put(pi.TargetObjectId,pi.Steps[currentStep -1].OriginalActorId);
              Map_setp.put(pi.TargetObjectId,pi.Steps.size());           
           }
        }
   }
   if(Map_APIupdate !=null && Map_APIupdate.size()>0){
       
           for(Campaign cm: trigger.new){
           
                cm.PromoField__c =cm.PromoField__c + Map_APIupdate.get(cm.id);
                  cm.PromoFieldType__c =cm.PromoFieldType__c + APIType;
                  cm.CurrentApprovaler__c = Map_CurrentApprovaler.get(cm.id);
                  cm.CurrentApprovalStep__c = Map_setp.get(cm.id);
           }
   }
 
}
Hello Everyone,

I am using dynamic choice varibale to get the values to be displayed as a radio button.Suppose user select the value "ABC" ,I need to query  object value and compare the value if they values matches i need to send to differnet screen.
Below is Screen shot
  • User-added image

Here it works has i am using the excat value like

{!OstomyOstomyKitsQA1} Equals to Irration-Skin(It want this value dynamic ,because down the line there is possiblity of changing the value) still i need to move to Screen 1

screen shot for decision
  • User-added image
Can you please guide me how to achevie this?
 
I have a triger that is duplicating opportunities when they are set to "Closed Won." When I create those duplicates, There are some events I need to add to them. Is this something I can do in my trigger?
HI Experts,

Could any one write test class for this please. thanks in advance.

public class TW_GeneralEmailDetails {
    public void setEMailDetails(String strToAddress, String strSubject, String strPlainTextBody){
        Messaging.Singleemailmessage email = new Messaging.Singleemailmessage();
        
        //Set Email Subject
        email.setSubject(strSubject);
        
        //Set ToAddress
        List<String> lstToAddresses;
        String[] toAddresses;
        if(strToAddress!=''&& strToAddress!=null){
          if(strToAddress.contains(',')){
            lstToAddresses=strToAddress.split(',');
            toAddresses = new String[] {lstToAddresses.get(0),lstToAddresses.get(1)};
          }
          else{
            toAddresses = new String[] {strToAddress};
          }
        }
        
        //String[] toAddresses = new String[] {strToAddress.split(',')};
        
        email.setToAddresses(toAddresses);
        //CH01.NEW.START -- Added empty list when there is no cc
        //Set CCAddress
        email.setCcAddresses(new List<String>());
        //CH01.NEW.END
        //Set Plain Text Body
        email.setPlainTextBody(strPlainTextBody);
        
        //Send it, ignoring any errors (bad!)
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }

    public void setEMailDetails(String strToAddress, String strSubject, String strCcAddress, String strPlainTextBody){
        Messaging.Singleemailmessage email = new Messaging.Singleemailmessage();
        
        //Set Email Subject
        email.setSubject(strSubject);
        
        //Set ToAddress
        List<String> lstToAddresses;
        String[] toAddresses;
        if(strToAddress!=''&& strToAddress!=null){
          if(strToAddress.contains(',')){
            lstToAddresses=strToAddress.split(',');
            toAddresses = new String[] {lstToAddresses.get(0),lstToAddresses.get(1)};
          }
          else{
            toAddresses = new String[] {strToAddress};
          }
        }
        
        //String[] toAddresses = new String[] {strToAddress.split(',')};
        
        email.setToAddresses(toAddresses);
        
        //Set CCAddress
        String[] ccAddresses = new String[] {strCcAddress };
        email.setCcAddresses(ccAddresses);
        
        //Set Plain Text Body
        email.setPlainTextBody(strPlainTextBody);
        
        //Send it, ignoring any errors (bad!)
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
    
Hai,
 Batch apex code for account filedupdate: Getting below error,can anybody help me?
[Error] Error: Compile Error: Argument type of global method must also be global: List<Account> at line 9 column 17

CODE:
global class Accountupdate implements Database.Batchable<sObject>
{
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        String query = 'SELECT Id,Name,Phone FROM Account ';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<Account> scope)
    {
        for (Account a : scope)
        {
           a.Phone='123';
        }
        update a;
    }  
    global void finish(Database.BatchableContext BC)
    {
    }
}
Hi Guys!!!

Adding code to already existing page using Cases obj.
Trying to show/hide fields using checkbox selection.
Thanks for your help!!!

<apex:pageBlockSectionItem id="SPContent">                                
                     <apex:inputField required="true"  value="{!c.SP_Topics__c}"  id="sptopics"   />
            </apex:pageBlockSectionItem>    
    
<apex:actionRegion>
    <apex:inputCheckbox value="{!c.SP_Selection__c}" id="SP" >
         <apex:actionSupport event="onchange" reRender="SPContent" status="status" />
         </apex:inputCheckbox>
     </apex:actionRegion>

     <apex:pageBlockSectionItem id="NonSPContent">
                       <apex:inputField required="true" value="{!c.Product__c}"  id="prd" />
               <apex:inputField required="true" value="{!c.Product_Type__c}"  id="ptype" />
         </apex:pageBlockSectionItem>

     <apex:actionRegion>
    <apex:inputCheckbox value="{!c.Non_SP_Selection__c}" id="NonSP" >
         <apex:actionSupport event="onchange" reRender="NonSPContent" status="status" />
         </apex:inputCheckbox>
     </apex:actionRegion>
here i send my code 
controller
-----------------
public with sharing class CustomPaginationController1 
{
    public Account acc {get;set;}   
    public ApexPages.StandardSetController con{get; set;} 
    public CustomPaginationController1 ()
    {
       acc = new Account();
       lstAccount = new List<Account>();
    }
    public List<Account> lstAccount 
    {  
        get  
        {  
            if(con != null)  
                return (List<Account>)con.getRecords();  
            else  
                return null ;  
        }  
        set;
    }  

    public PageReference Search()
    {
        String query= '';
        String strFilter = '';
        if(acc.Name != null && (acc.Name ).trim() !='')
        {
           strFilter  = strFilter  +  ' where Name Like \''+acc.Name+'%\'' ;
        }
        if(acc.Phone != null && (acc.Phone).trim() !='' )
        {
           if(strFilter == '')
           { 
               strFilter  = strFilter  +  ' where Phone like \''+acc.Phone+'%\'' ;
           }
           else
           {
               strFilter  = strFilter  +  ' And Phone like \''+acc.Phone+'%\'' ;
           }
        }
        if(strFilter != '')
        {
            query = 'Select name ,id, phone from Account '+strFilter+ ' limit 1000';
            System.debug('Query ---->'+ query );
            con = new ApexPages.StandardSetController(Database.getQueryLocator(query)); 
            con.setPageSize(2);
        }
        else
        {
        }
       return null;
    }
    public Boolean hasNext  
    {  
        get  
        {  
            return con.getHasNext();  
        }  
        set;  
    }  

    public Boolean hasPrevious  
    {  
        get  
        {  
            return con.getHasPrevious();  
        }  
        set;  
    }  
    public Integer pageNumber  
    {  
        get  
        {  
            return con.getPageNumber();  
        }  
        set;  
    }  
    public void previous()  
    {  
        con.previous();  
    }  
    public void next()  
    {  
        con.next();  
    }  
   
}

test class
-------------------------------
@isTest(seeAllData=true)
public class CustomPaginationController1_Test
{
    public static testmethod void test()
    {
       test.startTest();
        //inserting a record into Account object
        Account acc = new Account();
        acc.Name = 'Sample Test';
        acc.Phone = '8019982366';
        insert acc;
   
       //using pagereference inthe test class
       PageReference pg = page.Scenario_Vf_Page;
       pg.getparameters().put('id',string.valueOf(acc.id));
       test.setcurrentpage(pg);
       
       //calling the controller inthe test class
       CustomPaginationController1 cpc = new CustomPaginationController1();
       //cpc.lstAccount ();
       cpc.Search();
       //cpc.hasNext();
       test.stopTest();
     }
}

here how can i cover bold lines in the test class please help me any one
Hi Team,
This my apex controller and I wrote test class for this related but not working(test class).
Could you please help  me on this.
public class searchClientVisits{   
    List<Client_Visit__c> clientVisitList {get;set;}
    public Client_Visit__c clientInfo { get;set;}
    public SearchClientVisits(){  
        clientInfo = new Client_Visit__c ();
    } 
    //get a client visit list 
    public List<Client_Visit__c> getclientVisitList(){
        return clientVisitList;
    }
    //search the client records
    public void runSearch(){
        if(clientInfo.Start_Date__c != null && clientInfo.End_Date__c != null){
            Date startDate = clientInfo.Start_Date__c;
            System.debug('#####'+startDate); 
            Date endDate = clientInfo.End_Date__c;
            System.debug('#####'+endDate);            
            clientvisitList = [SELECT Id,Accounts__c,Start_Date__c,End_Date__c,Clients__c,Locations__c  FROM Client_Visit__c  WHERE Start_Date__c >= :startDate AND End_Date__c <=:endDate];
            System.debug('#####'+clientvisitList);     
        }       
    }
    public PageReference reset(){
        PageReference newpage = new PageReference(System.currentPageReference().getURL());
        newpage.setRedirect(true);
        return newpage;
    }
======================================================
Test class
@isTest
Public class clientVistTest{
   static testMethod void tsetSearchList() {
       clientvisitList cv = new  clientvisitList();
       clientvisitList = [SELECT Id,Accounts__c,Start_Date__c,End_Date__c,Clients__c,Locations__c  FROM Client_Visit__c  WHERE Start_Date__c >= :startDate AND End_Date__c <=:endDate];
       System.assert(!cv = null );
        Test.startTest();
        PageReference pageRef = Page.reset;
        Test.setCurrentPageReference(pageRef);
        Test.stopTest();
    }
}
 
  • July 01, 2015
  • Like
  • 0
I have this table

Platform        Status        Action
 
Platform1       OK           Setup | Edit
Platform2       NA           Setup | Edit
Platform3       OK           Setup | Edit

I want to remove " Setup | " when Status row is OK, else default.
How do I apply this?

here is my code for the table
<apex:pageBlock >
                    <apex:pageBlockTable value="{!platforms}" var="field" >
                        <apex:column headerValue="PLATFORM" value="{!field.Name}"/>
                        <apex:column headerValue="STATUS" value="{!field.Status__c}"/>
                        <apex:column headerValue="ACTION">
                                <apex:commandLink value="Setup" action="{!setup}"/>
                                <apex:outputText >&nbsp;&nbsp;|&nbsp;&nbsp;</apex:outputText>
                                <apex:commandLink value="Edit" action="{!defedit}">
                                </apex:commandlink>
                        </apex:column>
                        <apex:column />
                    </apex:pageBlockTable> 
                </apex:pageBlock>


Thanks!
when i editing the record by clicking edit link in the related list then it will navigate to custom vf page with standard controller and extension and then i have multiselect picklist in that page. 
My problem is when the page loaded by default the values in that multi slect picklist need to be highligted with blue colour means as selected value
i have custom setting object ,with Name and numebr fields, i want to shuffle number up and down using button s, can any one hlpe me with code