• CTISJH1
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 8
    Replies

I am unsure what I have done wrong in this test code. It is telling me I have 0% coverage but I feel like it should be telling me 100%. Below is my trigger and test code.

 

Trigger Code:

 

 

trigger storeID on Lead (before insert, before update) {
        
    //variable to hold store number    
    string storeNumber;
    
    //for loop to go through new trigger instances and assign Dealer_Number__c to store variable
    for(Lead l : Trigger.new)        
        storeNumber = l.Dealer_Number__c;
   
    //SOQL query to find account account(store) id from the account(store) that has the same AccountNumber as lead store number
    account a = [SELECT id FROM Account WHERE AccountNumber = :storeNumber];
        
    //for loop to go through trigger and assign account(store) id to lead lookup field Dealer__c
    for(Lead l : Trigger.new)
        l.Dealer__c = a.id; 
              
}

 Test Code:

 

@isTest
private class testLeadStoreIDs {

    static testMethod void myUnitTest() {
            
        account store = new account();
    	store.name = 'test store';
    	store.type = 'other';
    	store.AccountNumber = '123456';
    	insert store;

    	Lead[] leadsToCreate = new Lead[]{};
    	for(Integer x = 0; x<200; x++){
        	Lead l = new Lead();
        	l.LastName = 'last';
        	l.Company = 'test company';
        	l.Status = 'Open';
        	l.Dealer_Number__c = '123456';
    	}

    	//Test.startTest();
    	insert leadsToCreate;
    	//Test.stopTest();
    }
}

 Any advice on how I can get this test code to work would be appreciated. 

 

- Jim Hutcherson

 

 

I have a visualforce page that is used to get customer information. I want the form to disable an inputField that asks for the customers age if the customer checks the Do Not Disclose box. I have been unable to get this to work unless I use an inputText box and set it to a string variable.

 

Controller Code:

 

 

 public string age         { get; set; }       
 public boolean disclose   { get; set; }
 public boolean disable    { get; set; }
public void doDisable() {  
if(disclose == true) disable = true;  
if(disclose == false) disable = false;
}

 

 

VisualForce Page:

 

 

<apex:pageBlock id="agedisable" mode="edit"> 
                    
  <apex:actionRegion >
                         
    <apex:inputText value="{!age}" disabled="{!disable}"/>                          
    <apex:inputCheckbox value="{!disclose}">
        <apex:actionSupport event="onchange" action="{!doDisable}" reRender="agedisable"/>                              
    </apex:inputCheckbox> 
                    
  </apex:actionRegion>
                
</apex:pageBlock>

 

 

 

 I want to be able to use an inputField instead of an inputText field but when I try to disable an inputField or an inputText field set to an integer variable it will disable when I check the inputCheckbox but when I uncheck it, it remains disabled.

 

Also, when I have the age field set to string and it is able to disable and enable properly, once I check the checkbox the formatting of my page changes and a large space shows up between the checkbox field and the next field in my form. Is there a way to avoid this?

 

- Jim Hutcherson

 

 

 

 

I have created a trigger that takes the information put into an sObject we made and creates a new event. Most of the information is added to event fine but I am having trouble with the information from a Lookup Field. Instead of putting the text found in the lookup field it displays an ID number instead.

 

The Lookup Field would display a name like Company X but the event would display it as 001T000000CQ5KL

 

Is there anyway for me to diplay the lookup field as the literal text instead of the lookup field ID?

I am trying to create a trigger that will take information from a sObject we have created and use it to create a new public event. I found some code for a recurring event and I figured I could tweak it to create the events I am aiming for. The problem is that even though the code compiles fine, when I create a new record in our sObject I can not find the event that was supposed to be created. What am I missing?

 

 

trigger aClassTrigger on LGA__c (after insert) {
Map<String, LGA__c> clasMap = new Map<String, LGA__c>();
// after LGA are inserted
   List<Event> lgaEvents = new List<Event>();// build list in memory
   for (LGA__c clas : System.Trigger.new) {
    date t = clas.LGA_Date__c;
          datetime xStartDate = DateTime.newInstance(t.year(),t.month(),t.day());
   Event event = new Event(
    ActivityDate = clas.LGA_Date__c ,
    RecurrenceEndDateOnly = clas.End_Date__c ,
    RecurrenceStartDateTime = xStartDate,
    RecurrenceType = 'RecursEveryWeekday',
    RecurrenceDayofWeekMask = 1,
    IsRecurrence = TRUE,
    Description = 'Class Event.',
    Event_Type__c = 'Customer Training',
    Call_Objective__c = 'training',
    Location = 'here',
    IsAllDayEvent = TRUE,
    Event_Status__c = 'Not Started',
    Subject = 'Class trigger Event');
    lgaEvents.add(event);  // add to list
   }

}

Hi,

 

I have a Custom Object Called "Visit" which has  two custom date fields , StartDate__c and EndDate__c.

 

I have a Soql Query which needs to compare whether visit record is withinthe date range.

My SOQL query returns an error saying "List has No rows of data".

 

example: i have a visit record which has a start date as 2011-05-10 and End Date as 2011-05-17.

 

Can anyone point me what i am doing wrong?

 

Apex class:

 

public class visit {
    visit__c todaysvisit;
    String displayvisit;
    Date today=Date.Today();
  
    
    Public visit(){
        
        System.Debug('Todays date is >>>'+today);
        todaysvisit=[Select Visit__c From Visit__c Where Visit_Start_Date__ >= today AND Visit_End_Date__c <= today Limit 1 ];
        displayvisit=todaysvisit.visit__c;
        
    }
    
    Public Tip__c gettodaysvisit(){
        return todaysvisit;
    }
    
    Public String getdisplayvisit(){
        return displayvisit;
    }
    
   
}

 

 

Thanks,

Sales4ce

 

Hi Friends I am looking for SFDC developer support if any one have information please forward me

Thanks

Neeraj.

For a multi select list view JS button, I have some record length conditonals (records[0] == null or records [1] != null).

 

Is there an easy syntax for all records? If "all records are selected from the multi select list"...

 

I googled around, I think what I need is a way to determine the max # of IDs in the record array, and if the # recordIDs I select from that equals, then I know i've selected all the records.

  • May 09, 2011
  • Like
  • 0

I am unsure what I have done wrong in this test code. It is telling me I have 0% coverage but I feel like it should be telling me 100%. Below is my trigger and test code.

 

Trigger Code:

 

 

trigger storeID on Lead (before insert, before update) {
        
    //variable to hold store number    
    string storeNumber;
    
    //for loop to go through new trigger instances and assign Dealer_Number__c to store variable
    for(Lead l : Trigger.new)        
        storeNumber = l.Dealer_Number__c;
   
    //SOQL query to find account account(store) id from the account(store) that has the same AccountNumber as lead store number
    account a = [SELECT id FROM Account WHERE AccountNumber = :storeNumber];
        
    //for loop to go through trigger and assign account(store) id to lead lookup field Dealer__c
    for(Lead l : Trigger.new)
        l.Dealer__c = a.id; 
              
}

 Test Code:

 

@isTest
private class testLeadStoreIDs {

    static testMethod void myUnitTest() {
            
        account store = new account();
    	store.name = 'test store';
    	store.type = 'other';
    	store.AccountNumber = '123456';
    	insert store;

    	Lead[] leadsToCreate = new Lead[]{};
    	for(Integer x = 0; x<200; x++){
        	Lead l = new Lead();
        	l.LastName = 'last';
        	l.Company = 'test company';
        	l.Status = 'Open';
        	l.Dealer_Number__c = '123456';
    	}

    	//Test.startTest();
    	insert leadsToCreate;
    	//Test.stopTest();
    }
}

 Any advice on how I can get this test code to work would be appreciated. 

 

- Jim Hutcherson

 

 

I am trying to create a trigger that will take information from a sObject we have created and use it to create a new public event. I found some code for a recurring event and I figured I could tweak it to create the events I am aiming for. The problem is that even though the code compiles fine, when I create a new record in our sObject I can not find the event that was supposed to be created. What am I missing?

 

 

trigger aClassTrigger on LGA__c (after insert) {
Map<String, LGA__c> clasMap = new Map<String, LGA__c>();
// after LGA are inserted
   List<Event> lgaEvents = new List<Event>();// build list in memory
   for (LGA__c clas : System.Trigger.new) {
    date t = clas.LGA_Date__c;
          datetime xStartDate = DateTime.newInstance(t.year(),t.month(),t.day());
   Event event = new Event(
    ActivityDate = clas.LGA_Date__c ,
    RecurrenceEndDateOnly = clas.End_Date__c ,
    RecurrenceStartDateTime = xStartDate,
    RecurrenceType = 'RecursEveryWeekday',
    RecurrenceDayofWeekMask = 1,
    IsRecurrence = TRUE,
    Description = 'Class Event.',
    Event_Type__c = 'Customer Training',
    Call_Objective__c = 'training',
    Location = 'here',
    IsAllDayEvent = TRUE,
    Event_Status__c = 'Not Started',
    Subject = 'Class trigger Event');
    lgaEvents.add(event);  // add to list
   }

}