• ibtesam
  • NEWBIE
  • 250 Points
  • Member since 2012

  • Chatter
    Feed
  • 9
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 88
    Replies

 Hai.............

 

              I had one problem regarding Dynamic search....

         I Had one custom object (Candidate) and input fields First Name ,LastName , City, Education  etc.....

On my visual force page, without typing any value in the input text field the values are displaying automatically and when i enter any value in the input field ERROR msg is displaying even the record is present

 

 

MY visualforce code :

<apex:page controller="CandidateSearchController" sidebar="false">
 <script type="text/javascript">
      function doSearch() {
        searchServer(
          document.getElementById("First_Name__c").value,
          document.getElementById("Last_Name__c").value,
          document.getElementById("City__c").value,
          document.getElementById("Education__c").options[document.getElementById("Education__c").selectedIndex].value
          );
      }
      </script> 
 
  <apex:form >
  <apex:pageMessages id="errors" />
 
  <apex:pageBlock title="Find Me A Candidate!" mode="edit">
 
  <table width="100%" border="0">
  <tr>  
    <td width="200" valign="top">
 
      <apex:pageBlock title="Parameters" mode="edit" id="criteria">
 
       
 
      <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
          <apex:param name="First_Name__c" value="" />
          <apex:param name="Last_Name__c" value="" />
          <apex:param name="City__c" value="" />
          <apex:param name="Education__c" value="" />
      </apex:actionFunction>
 
      <table cellpadding="2" cellspacing="2">
      <tr>
        <td style="font-weight:bold;">First Name<br/>
        <input type="text" id="First_Name__c" onkeyup="doSearch();"/>
        </td>
      </tr>
      <tr>
        <td style="font-weight:bold;">Last Name<br/>
        <input type="text" id="Last_Name__c" onkeyup="doSearch();"/>
        </td>
      </tr>
      <tr>
        <td style="font-weight:bold;">City<br/>
        <input type="text" id="City__c" onkeyup="doSearch();"/>
        </td>
      </tr>
      <tr>
        <td style="font-weight:bold;">Education<br/>
          <select id="Education__c" onchange="doSearch();">
            <option value=""></option>
            <apex:repeat value="{!Education }" var="edc">
              <option value="{!edc}"> {!edc}</option>
            </apex:repeat>
          </select>
        </td>
      </tr>
      </table>
 
      </apex:pageBlock>
 
    </td>
    <td valign="top">
 
    <apex:pageBlock mode="edit" id="results">
 
        <apex:pageBlockTable value="{!candidates}" var="candidate">
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="First Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="first_name__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Candidate.First_Name__c}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Last Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="last_Name__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!candidate.Last_Name__c}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="City" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="City__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!candidate.City__c}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Education" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Education__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!candidate.Education__c}"/>
            </apex:column>
 
        </apex:pageBlockTable> 
 
    </apex:pageBlock> 
 
    </td>
  </tr>
  </table>
 
  <apex:pageBlock title="Debug - SOQL" id="debug">
      <apex:outputText value="{!debugSoql}" />           
  </apex:pageBlock>    
 
  </apex:pageBlock>
 
  </apex:form>
 
</apex:page>

 

 

 

here is my Controller code;

 

public with sharing class CandidateSearchController {   
    
    private String soql {get;set;}
    // the collection of contacts to display
      Public List<Candidate__c> candidates {get;set;}
    // the current sort direction. deaults 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 = 'Last_Name__c'; } 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 contrller and display some sample data when the page loads
          public CandidatesearchController() {
            soql='select First_name__c,Last_name__c,City__c,Education__c from Candidate__c where Candidate__c.First_name__c != 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 actualquery
           public void runQuery() {
              try {
                   candidates = 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('First_Name__c');
    String LastName = Apexpages.currentPage().getParameters().get('Last_Name__c');
    String City = Apexpages.currentPage().getParameters().get('City__c');
    String Education = Apexpages.currentPage().getParameters().get('Education__c');
 
    soql='select First_name__c,Last_name__c,City__c,Education__c from Candidate__c where Candiadate__c.First_Name__c != null';    

    if (!FirstName.equals(''))
      soql += ' and First_Name__c LIKE \' '+String.escapeSingleQuotes(FirstName)+'%\'';
    if (!LastName.equals(''))
      soql += ' and Last_Name__c LIKE \''+String.escapeSingleQuotes(LastName)+'%\'';
    if (!City.equals(''))
      soql += ' and City__c LIKE \''+String.escapeSingleQuotes(city)+'%\'';  
    if (!Education.equals(''))
      soql += ' and Education__c LIKE (\''+Education+'\')';
 
    // run the query again
    runQuery();
 
    return null;
  }
 
  // use apex describe to build the picklist values
  public List<String> Education {
    get {
      
      
      
      if (Education == null) {
 
        Education = new List<String>();
        Schema.DescribeFieldResult field = Candidate__c.Education__c.getDescribe();
 
        for (Schema.PicklistEntry f : field.getPicklistValues())
         Education.add(f.getLabel());
 
      }
      return Education;          
    }
    set;
  }
 
}

 

Hi there,

 

Wrote a custom controller to display an overall view of all our services, but the test method is returning a "System.NullPointerException: Attempt to de-reference a null object" on this line:

 

@IsTest(SeeAllData=true)
public static void testServiceTimeline() {				
		
	ServiceTimeline controller = new ServiceTimeline();		
		
}

 

This is my controller:

 

public class ServiceTimeline {
	
	public List<ServiceTime> serviceList { get; set; }
	
	public ServiceTimeline() {
		
		List<Service__c> ListOfServices= [
			SELECT 
				Name, 
				RecordType.Name,
				Address_Single_Line__c,
				Status__c,
				CreatedDate,
				Stage_Prospect__c, 
				Stage_Site_Survey__c, 
				Stage_Scheduling_Install__c, 
				Stage_Provisioning__c, 
				Stage_Pending_Billing__c, 
				Stage_Order_Received__c, 
				Stage_Order_Completion__c, 
				Stage_Obtaining_Install_Approval__c, 
				Stage_Awaiting_Install__c,
				Stage_Design_Request__c
			FROM 
				Service__c 
			WHERE 
				Status__c NOT IN ('Order Completion', 'Cancelled', 'Stalled', 'Unserviceable')
				AND RecordType.Name NOT IN ('Prospect','Ethernet Interconnect')
			];
		
		if (ListOfServices.size() > 0) {
			for (Service__c tempService : ListOfServices) {
				serviceList.add(new ServiceTime(tempService));
			}
		} else {
			Util.addERRORMessage('No Services are currently being installed.');
		}
		
	}
}

 

Any help would be appreciated.

 

Hello Alll,

 

I have been reading the force.com manual .

I came accross below line 

 

"Starting with Apex code saved using Salesforce.com API version 24.0, test methods don’t have access by default to pre-

existing data in the organization."

 

link http://www.salesforce.com/us/developer/docs/apexcode/index.htm

 

What does this mean? Does it mean I can't write a soql inside my test class. 

Please help me clarify my understanding.

 

Thanks a ton!!!

 

 

  • February 17, 2013
  • Like
  • 0

What is functionality of visualforce?

 

 

 

Thanks

SFDC_Learner

 

 

I need to AJAX toolkit for call apex method.  But disrupt to work updateInput(t) and other all function when I add first two line to vf code. How can I solve this problem?

 

    <apex:includeScript value="/soap/ajax/27.0/connection.js"/>
    <apex:includeScript value="/soap/ajax/27.0/apex.js"/>
    <script>
        function updateInput(t){
            var a = 72;
            for(var i=0;i<10;i++)
                document.getElementById("j_id0:j_id2:j_id30:j_id" + (a + i*25)).value = t.value;
        function setId(id){
            var name = sforce.apex.execute("AddMultipleEvent","getAccountShortName", {projectId:id}); 
            var a = 51;
            for(var i=0;i<10;i++)
                document.getElementById("j_id0:j_id2:j_id30:j_id" + (a + i*25)).value = name;
        }
    </script>

 

unable to login unable to Create Force.com Project from Eclipse IDE! 

the error message  is "unable to connect to Hostname 'www.salesforce.com"

invalid username,password,security token or user bloked.

please verify and/or change your Credentials"

  • January 27, 2013
  • Like
  • 0

What is Web-to-case and Email-to-case With example?

 

 

 

Thanku,

SFDC-Learner

When i am opening developer console i am getting this error message :

Requested entity 07LK0000000nKzE was not found. Error open request failed.

and Failed to load entity.

hi i have two fields in my contact object like leadsource and level.

i want to get these values using if condition like

string s='level';

 if(type==s)
            {
                Schema.DescribeFieldResult pickval  =Schema.sObjectType.contact.fields.(:s).getSObjectField().getDescribe();
            }
i have to mension field name dynamically.

please help me.         

We can create Objects eg Album__c in developerforce.com and in Database.com as well...Whats the difference?

I want to find the diatance between two places. I'm creating custom object with a custom field of data type Geolocation. What should I do next?

Hi Team,

 

Could you please any one help me with below code.

 

I am getting attempt derernce a null object  at this part

 

public PageReference addProducts() {
        List<Case_Product__c> cpsToBeInserted = new List<Case_Product__c>();
        
        for (LabelWrapper clw : labels) {
            if (clw.isSelected) {
                system.debug('Naresh');
                cpsToBeInserted.add(new Case_Product__c(Case__c = caseId, Product_Shipper__c = clw.cl.Id));
            }
        }
   

 

------------------------------------------------------------------------------------------

 


public with sharing class AddCaseProducts {

    public List<LabelWrapper> labels{get; set;}
    public List<SelectOption> productFamilies{get; set;}
    public String productFamily{get; set;}
    Id caseId;
    
    public AddCaseProducts(ApexPages.StandardController controller) {
        caseId = ApexPages.currentPage().getParameters().get('caseId');
        productFamilies= new List<SelectOption>();
        productFamily= '';
        
        for (PicklistEntry pe : Schema.SObjectType.Product_Shipper__c.Fields.Family__c.getpicklistValues()) {
            productFamilies.add(new SelectOption(pe.getValue(), pe.getLabel()));
        }
    }
    
    public void initialize() {
        if (caseId != null) {
            labels = new List<LabelWrapper>();
            //String campaignType = [select RecordType.Name from Campaign where Id=:campaignId].RecordType.Name;
            List<Id> existingCPs = new List<Id>();
            
            for (Case_Product__c cp : [SELECT Product_Shipper__c FROM Case_Product__c WHERE Case__c = :caseId])
                existingCPs.add(cp.Product_Shipper__c);
            String query = 'SELECT Id, Name, Family__c,AGI_Code__c,Pack_Size__c,Price__c FROM Product_Shipper__c WHERE Id NOT IN :existingCPs';
            if (productFamily!= null && productFamily!= '') {
                query += ' AND Family__c INCLUDES (:productFamily)';
                
                system.debug('Naresh');
            }
            List<Product_Shipper__c> prodList = Database.query(query);
            for (Product_Shipper__c l : prodList)
                labels.add(new LabelWrapper(l));
            if (labels.isEmpty()) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.INFO, 'There are no products to display'));
            }
        }
        else {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.FATAL, 'Please open this page from Case detail page'));
        }
    }
    
    public PageReference addProducts() {
        List<Case_Product__c> cpsToBeInserted = new List<Case_Product__c>();
        
        for (LabelWrapper clw : labels) {
            if (clw.isSelected) {
                system.debug('Naresh');
                cpsToBeInserted.add(new Case_Product__c(Case__c = caseId, Product_Shipper__c = clw.cl.Id));
            }
        }
        
        if (!cpsToBeInserted.isEmpty()) {
            try {
                insert cpsToBeInserted;
                
                return new ApexPages.StandardController(new Case(Id = caseId)).view();
            }
            catch(System.DMLException e) {
                ApexPages.addMessages(e);
            }
        }
        else {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.FATAL, 'Please select atleast a product to insert or click cancel to go back'));
        }
        return null;
    }
    
    public PageReference cancel() {
        if (caseId != null) {
            return new ApexPages.StandardController(new Case(Id = caseId)).view();
        }
        return new PageReference('/home/home.jsp');
    }
    
    class LabelWrapper {
        public boolean isSelected{get; set;}
        public Product_Shipper__c cl {get; set;}
        
        public LabelWrapper(Product_Shipper__c cl) {
            this.cl = cl;
        }
    }

}

  • March 03, 2013
  • Like
  • 0

 Hai.............

 

              I had one problem regarding Dynamic search....

         I Had one custom object (Candidate) and input fields First Name ,LastName , City, Education  etc.....

On my visual force page, without typing any value in the input text field the values are displaying automatically and when i enter any value in the input field ERROR msg is displaying even the record is present

 

 

MY visualforce code :

<apex:page controller="CandidateSearchController" sidebar="false">
 <script type="text/javascript">
      function doSearch() {
        searchServer(
          document.getElementById("First_Name__c").value,
          document.getElementById("Last_Name__c").value,
          document.getElementById("City__c").value,
          document.getElementById("Education__c").options[document.getElementById("Education__c").selectedIndex].value
          );
      }
      </script> 
 
  <apex:form >
  <apex:pageMessages id="errors" />
 
  <apex:pageBlock title="Find Me A Candidate!" mode="edit">
 
  <table width="100%" border="0">
  <tr>  
    <td width="200" valign="top">
 
      <apex:pageBlock title="Parameters" mode="edit" id="criteria">
 
       
 
      <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
          <apex:param name="First_Name__c" value="" />
          <apex:param name="Last_Name__c" value="" />
          <apex:param name="City__c" value="" />
          <apex:param name="Education__c" value="" />
      </apex:actionFunction>
 
      <table cellpadding="2" cellspacing="2">
      <tr>
        <td style="font-weight:bold;">First Name<br/>
        <input type="text" id="First_Name__c" onkeyup="doSearch();"/>
        </td>
      </tr>
      <tr>
        <td style="font-weight:bold;">Last Name<br/>
        <input type="text" id="Last_Name__c" onkeyup="doSearch();"/>
        </td>
      </tr>
      <tr>
        <td style="font-weight:bold;">City<br/>
        <input type="text" id="City__c" onkeyup="doSearch();"/>
        </td>
      </tr>
      <tr>
        <td style="font-weight:bold;">Education<br/>
          <select id="Education__c" onchange="doSearch();">
            <option value=""></option>
            <apex:repeat value="{!Education }" var="edc">
              <option value="{!edc}"> {!edc}</option>
            </apex:repeat>
          </select>
        </td>
      </tr>
      </table>
 
      </apex:pageBlock>
 
    </td>
    <td valign="top">
 
    <apex:pageBlock mode="edit" id="results">
 
        <apex:pageBlockTable value="{!candidates}" var="candidate">
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="First Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="first_name__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Candidate.First_Name__c}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Last Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="last_Name__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!candidate.Last_Name__c}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="City" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="City__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!candidate.City__c}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Education" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Education__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!candidate.Education__c}"/>
            </apex:column>
 
        </apex:pageBlockTable> 
 
    </apex:pageBlock> 
 
    </td>
  </tr>
  </table>
 
  <apex:pageBlock title="Debug - SOQL" id="debug">
      <apex:outputText value="{!debugSoql}" />           
  </apex:pageBlock>    
 
  </apex:pageBlock>
 
  </apex:form>
 
</apex:page>

 

 

 

here is my Controller code;

 

public with sharing class CandidateSearchController {   
    
    private String soql {get;set;}
    // the collection of contacts to display
      Public List<Candidate__c> candidates {get;set;}
    // the current sort direction. deaults 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 = 'Last_Name__c'; } 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 contrller and display some sample data when the page loads
          public CandidatesearchController() {
            soql='select First_name__c,Last_name__c,City__c,Education__c from Candidate__c where Candidate__c.First_name__c != 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 actualquery
           public void runQuery() {
              try {
                   candidates = 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('First_Name__c');
    String LastName = Apexpages.currentPage().getParameters().get('Last_Name__c');
    String City = Apexpages.currentPage().getParameters().get('City__c');
    String Education = Apexpages.currentPage().getParameters().get('Education__c');
 
    soql='select First_name__c,Last_name__c,City__c,Education__c from Candidate__c where Candiadate__c.First_Name__c != null';    

    if (!FirstName.equals(''))
      soql += ' and First_Name__c LIKE \' '+String.escapeSingleQuotes(FirstName)+'%\'';
    if (!LastName.equals(''))
      soql += ' and Last_Name__c LIKE \''+String.escapeSingleQuotes(LastName)+'%\'';
    if (!City.equals(''))
      soql += ' and City__c LIKE \''+String.escapeSingleQuotes(city)+'%\'';  
    if (!Education.equals(''))
      soql += ' and Education__c LIKE (\''+Education+'\')';
 
    // run the query again
    runQuery();
 
    return null;
  }
 
  // use apex describe to build the picklist values
  public List<String> Education {
    get {
      
      
      
      if (Education == null) {
 
        Education = new List<String>();
        Schema.DescribeFieldResult field = Candidate__c.Education__c.getDescribe();
 
        for (Schema.PicklistEntry f : field.getPicklistValues())
         Education.add(f.getLabel());
 
      }
      return Education;          
    }
    set;
  }
 
}

 

Hello,

 

I have the following trigger and it keeps causing this error: "System.Exception: Too many SOQL queries: 101". Can anyone help me to update this code so that it is not in a loop? I've been trying and struggling with it a bit.

 

Thank you!

 

Danielle

 

 

trigger LeadOppStageName on Task (before insert, before update, after insert){
// Goal: Pull fields from the lead record for tracking activities related to lists and to discern in which lead stages these activities occured

// If related to a Lead, query to find out the Lead ID, Lead Stage, and Lead Source Detail

// Create collection of tasks that are related to an lead (where the lead is listed only once)
    Set<Id> leadIds = new Set<Id>();
    for(Task t : trigger.new){
        String wId = t.WhoId;
        if(wId!=null && wId.startsWith('00Q') && !leadIds.contains(t.whoId)){
            leadIds.add(t.WhoId);
        }
    }
    // Pull in lead ids and related field to populate task record
    List<Lead> taskLead  = [Select Id, leadsource, lead_source_detail__c, Lead_Stage__c, Lead_Channel__c, Lead_Partner_Program__c, Lead_Segment__c,
    Original_Lead_Channel__c, Original_Lead_Partner_Program__c, Original_Lead_Segment__c from Lead where Id in :leadIds limit 1];
    Map<Id, Lead> leadMap = new Map<Id, Lead>();
    for(Lead l : taskLead){
        leadMap.put(l.Id,l);
    }
    
    // Update custom task field with custom lead field
    for(Task t : trigger.new){
        String wId = t.WhoId;
        if(wId!=null && wId.startswith('00Q')){
           Lead thisLead = leadMap.get(t.WhoId);
            if(thislead!=null){t.Sales_Stage__c = thisLead.Lead_Stage__c;} 
            if(thislead!=null){t.Lead_Source__c = thisLead.LeadSource;}            
            if(thislead!=null){t.record_type__c = 'Lead';}
            if(thislead!=null){t.lead_source_detail__c = thislead.Lead_source_detail__c;}           
            if(thislead!=null){t.Lead_Channel__c = thislead.lead_channel__c;} 
            if(thislead!=null){t.Original_Lead_Channel__c = thislead.original_lead_channel__c;}             
            if(thislead!=null){t.lead_partner_program__c = thislead.lead_partner_program__c;}
            if(thislead!=null){t.Original_lead_partner_program__c = thislead.Original_lead_partner_program__c;} 
            if(thislead!=null){t.lead_segment__c = thislead.lead_segment__c;}
            if(thislead!=null){t.Original_lead_segment__c = thislead.Original_lead_segment__c;}            

}
}
}

Hi there,

 

Wrote a custom controller to display an overall view of all our services, but the test method is returning a "System.NullPointerException: Attempt to de-reference a null object" on this line:

 

@IsTest(SeeAllData=true)
public static void testServiceTimeline() {				
		
	ServiceTimeline controller = new ServiceTimeline();		
		
}

 

This is my controller:

 

public class ServiceTimeline {
	
	public List<ServiceTime> serviceList { get; set; }
	
	public ServiceTimeline() {
		
		List<Service__c> ListOfServices= [
			SELECT 
				Name, 
				RecordType.Name,
				Address_Single_Line__c,
				Status__c,
				CreatedDate,
				Stage_Prospect__c, 
				Stage_Site_Survey__c, 
				Stage_Scheduling_Install__c, 
				Stage_Provisioning__c, 
				Stage_Pending_Billing__c, 
				Stage_Order_Received__c, 
				Stage_Order_Completion__c, 
				Stage_Obtaining_Install_Approval__c, 
				Stage_Awaiting_Install__c,
				Stage_Design_Request__c
			FROM 
				Service__c 
			WHERE 
				Status__c NOT IN ('Order Completion', 'Cancelled', 'Stalled', 'Unserviceable')
				AND RecordType.Name NOT IN ('Prospect','Ethernet Interconnect')
			];
		
		if (ListOfServices.size() > 0) {
			for (Service__c tempService : ListOfServices) {
				serviceList.add(new ServiceTime(tempService));
			}
		} else {
			Util.addERRORMessage('No Services are currently being installed.');
		}
		
	}
}

 

Any help would be appreciated.

 

hey all,

 

Here's a simple trigger.

 

There are 2 for loops and a soql query to loop through.

 

comparing the WBS2 values, I update the WBS2 order from WBS_2_Order__c object to SPM object.

 

how can I refine it to reduce the no of script statements/no of soql queries? Using maps? (any samples)

 

trigger SPMUpdateWBS2Order on Site_Progress_Monitoring__c (before insert,before update) {

    List<WBS_2_Order__c> wbs2OrderList = [Select Id,Name,WBS_2__c,WBS_2_Order__c FROM WBS_2_Order__c]; 
    
    for(Site_Progress_Monitoring__c spm: trigger.new){
        for(WBS_2_Order__c wb2Order: wbs2OrderList){
            if(spm.WBS_2__c == wb2Order.WBS_2__c)
                spm.WBS_2_Order__c = wb2Order.WBS_2_Order__c;
        }
    }    
}

 

Cheers!

Hi All

I have written a trigger on opportunity , it will trigger before insert and.

when the created opportunity's is associated to some campaign ,

then I tried to get campaign vendor(custom object ) which is associated to campaign, and tried to update a field in that custom object.

The trigger which i have written is not working fine and I have pasted that below .

can anyone help me out of this.

Trigger:
trigger vendoramount on Opportunity (before insert)
{
for (Opportunity t : trigger.new)
{
if (t.CampaignId!= null & t.LeadSource=='Web' )
 {
    List<Opportunity> opp=[Select CampaignId ,LeadSource From Opportunity Where CampaignId =:t.CampaignId limit 1 ];
    for(Opportunity o:opp)
    {
    List<CampaignVendor__c> cv=[Select Campaign__c,vendoramount__c From CampaignVendor__c where Campaign__c =:o.CampaignId ];
    for(CampaignVendor__c cc:cv)
    {
    cc.vendoramount__c= t.Amount ;
    }
    }
 }
}
}

Hi Community,

 

We have few fields from the groovy script managed package. These fields are not visible in the dataloader .

 

One more intresting thing is they are visible for the dev, fulltest sandboxes. But the fields in the production are not visible in the dataloader even in the ETL tools. 

 

I chek the field level security by field wise and profile wise both fulltest which genereated from the production  and Production. 

I did not find any difference.

 

Do any body share your experience to overcome this.

I appricate your for your time and help.

 

Trying to figure out why my production coverage is now only getting 66% coverage.  The code is identical to the Sandbox? Any suggestions?

Trigger:

 

trigger OSC_Activty_Event on Event (after update) {
2
3 for (Event updatedEvent : trigger.new) {
4 for(Event olduEvent : trigger.old){
5 if (updatedEvent.Sales_Call_Completed__c != olduEvent.Sales_Call_Completed__c){
6 for(Account a : [SELECT id, Last_Sales_Call__c FROM Account WHERE Account.id = :updatedEvent.AccountId]){
7
8 a.Last_Sales_Call__c = updatedEvent.Completed_Date_Time__c;
9 update a;
10
11 }
12
13 }
14 }
15
16
17 }
18 }

 

Apex Class:

 

@isTest
private class OSC_Event_Test {

static testMethod void myUnitTest() {
// TO DO: implement unit test
Event ev = [Select id,Sales_Call_Completed__c from Event where Sales_Call_Completed__c = 'No' limit 1];
ev.Sales_Call_Completed__c = 'Yes'; ev.All_Communities_Objective__c = 'Sell a Paid Model';
try{
update ev;
//System.assertEquals('This is a test');
}
catch(System.DmlException e){
System.debug('we caught a dml exception: ' + e.getDmlMessage(0));
}
}
}

  • February 18, 2013
  • Like
  • 0

Hi 

 

 I have 

 

1.Service Order (parent) is Assigning to multiple technicians (Contacts)

 

 When Technician is login into customer portal in one Visualforce pages I am showing all the Service Orders of that particular Contact(Technician).

 

 up to here it is working fine.

 

Here the Technician (Contact) Can enter Time, material, Expense ones he enter time if I am clicking save it is giving an error.

 

  I have given New,Edit,Delete  permissions my license is Customer Portal Manager Standard 

 

  Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

Error is in expression '{!saveAndNew}' in component <apex:page> in page fconnect:technician_time_entry
Any help is Appreciated.
  • February 18, 2013
  • Like
  • 0

<apex:column value="{!houses.name}">
                 <apex:facet name="header"><apex:inputCheckbox value="{!chkhousehold_lname}">Name</apex:inputCheckbox>
                 <Apex:actionSupport event="onchange"  action="{!householdInputCheck}" rerender="hldSection" />
                 </apex:facet>
             </apex:column>

 

 

By doing this my checkboxes are getting vanished and i cant select the checkbox

Hello Alll,

 

I have been reading the force.com manual .

I came accross below line 

 

"Starting with Apex code saved using Salesforce.com API version 24.0, test methods don’t have access by default to pre-

existing data in the organization."

 

link http://www.salesforce.com/us/developer/docs/apexcode/index.htm

 

What does this mean? Does it mean I can't write a soql inside my test class. 

Please help me clarify my understanding.

 

Thanks a ton!!!

 

 

  • February 17, 2013
  • Like
  • 0

Hi,

 

I am doing mass update in a class and while doing mass operation i am checking duplicate record based on some condition for this i am calling a method again and again and getting this error can anyone please help how i can bulkyfy my code.code is below,your help will be really appreciated:

 

public static List<String> checkDuplicatestudentdatamasschange(Student__c studobj){

Date effectiveDate = studobj.Effective_Date__c;
Date expirationDate= studobj.Expiration_Date__c;
List<String> duplicatesS= new List<String>();
String studentrecordid= studobj.Parent_Student__c;
List<Student__c> studsupport= null;
String soql = 'select id,Parent_Student__c,name,Agreement_Number__c from Student__c where (status__c=\'Approved\' OR status__c =\'Awaiting Approval\' OR status__c =\'Awaiting Stu Approval\' OR status__c =\'Conditionally Approved\' OR status__c =\'Rejected by Stud\')';

if (studobj.Supplier_Profile_ID__c!=null)
soql += ' and Student_Profile_ID__c = \''+studobj.Student_Profile_ID__c+'\'';
if (studobj.teacher__c!=null)
soql += ' and teacher___c = \''+studobj.teacher__c+'\'';
System.debug('----------soql-------------------'+soql);

try {
studsupport= Database.query(soql + ' order by Effective_Date__c asc' );
} catch (Exception e) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
}
if(studsupport!=null && !studsupport.isEmpty()){

for(Student__c support:studsupport){
duplicatesS.add(support.Agreement_Number__c);
}

}
System.debug('----------duplicates-------------------'+duplicatesPS);
return duplicatesS;
}

 

 

Thanks:))))

  • February 16, 2013
  • Like
  • 0

Hi All,

 

I'm unable to publish Site.com sites that I created while working on "Site.com".

 

I have 'Site.com Publisher User' permissions and also "Publisher role at the site level" but the

'Publish Changes' button is not visible in my overview tab.

 

Is there some thing that I'm missing.

 

Thanks in Advance,

JSmith

Hi all, got a weird issue.  I'm trying to test run some batch apex in my sandbox using the developer console to schedule immediate runs and I'm hitting a weird issue.

 

I'm trying to query a custom currency field caled Total_Won_This_Year__c but it's not being returned in my results.  I'm on the standard System Administrator profile so I should have no access problems with regard to field level security (which is set to editable anyway), the query runs and doesn't error out but when I try to access the field I get null exceptions and when I look in the debug logs I see the field isn't in the results.  I'm on the Enterprise Edition.

 

atrb.query = 'SELECT Id, CurrencyIsoCode, Total_Won_This_Year__c FROM Account';
...
return Database.getQueryLocator(query);
...
DEBUG|query = (Account:{CurrencyIsoCode=EUR, Id=001e0000004pCLSAA2}

Anyone know why I'd be having this issue?  I need to query the field and update a value and I'm using a batch so I can run it monthy.

 

Thanks

how can i put checkboxes for <apex:outputfield> ?? the outfield contains fields from my standard controller ..i need to attach those fields with checkboxes

Are there any multilingual capabilities with Force.com Sites?