• ganesh mamidala
  • -2 Points
  • Member since 2018

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
  • 7
Hi All,

Need help improving my test class. Current coverage is 47%!

VF Page
<apex:page controller="WorkCtr" lightningStylesheets="true" >
    <apex:slds />
    <div class="slds-scope">
        <apex:form >
            <apex:pageBlock >
                <apex:pageblocksection columns="2">                     
                    <apex:inputField value="{!wr.Date__c}"/>                    
                    <apex:inputField value="{!wr.Name__c}"/>  
                    <apex:inputField value="{!wr.Comment__c}"/>     
                <apex:pageBlockSection columns="1">
                    <apex:pageBlockTable value="{!walist}" var="wa">
                        <apex:column headerValue="Percentage">
                            <apex:inputField value="{!wa.Percentage__c}"/>
                        <apex:column headerValue="Assigned To">
                            <apex:inputField value="{!wa.Assigned_to__c}"/>
                <apex:pageBlockButtons location="bottom">
                    <apex:commandButton value="Save" action="{!save}" />    
                    <apex:commandButton value="Add Row" action="{!AddRow}" immediate="true"/>
APEX Class
public with sharing class WorkCtr {

    public Workload__c wr{get;set;}
    public list <Work__c> walist{get;set;}    
    public WorkCtr() {  
        wr = new Workload__c();
        walist = new List <Work__c>();
    public void AddRow(){
        walist.add(new Work__c());
    public void save(){        
        if(wr.name__c !=null){
            insert wr;
            List <Work__c> wal = new List <Work__c>();
            for (Work__c w: walist) {
                w.Workload__c = wr.Id;   
                w.Date__c = wr.Date__c;
            if(wal !=null) {
                insert wal;
        wr = new Workload__c();
        walist = new List <Work__c>();
Test Class
private class WorkCtrTest {
    static testMethod void WorkCtrTest(){
        Account acc = new Account();
        acc.Name = 'Test Account';
        insert acc ;
        Contact con = new Contact();
        con.AccountId = acc.Id;
        con.LastName ='Test Name';
        insert con;
        Contact con1 = new Contact();
        con1.AccountId = acc.Id;
        con1.LastName ='Test Name';
        insert con1;
        Workload__c wr = new Workload__c();
        wr.Comment__c = 'This a test comment';
        wr.Name__c = con.Id;
        wr.Date__c = System.Today();       
        insert wr;    
        Work__c w = new Work__c();
        w.Assigned_to__c = con.Id ;
        w.Date__c = wr.Date__c;
        w.Percentage__c = 50;
        w.Workload__c = wr.Id;       
        insert w;
        Work__c w1 = new Work__c();
        w1.Assigned_to__c = con1.Id ;
        w1.Date__c = wr.Date__c;
        w1.Percentage__c = 30;
        w1.Workload__c = wr.Id; 
        insert w1;
        WorkCtr obj = new WorkCtr();           

Thanks in advance for your help.
Hi Guys,

How can we show lightning component in List View ?
is there any way ?


Hi All,

I want implement Time-Dependent WF Action for 15 days before the due date. Will it send email-alter to every day before the due date(I mean all 15 days)?

Thanks in advance!



public class AboutController {
 public  List<MyProduct__c> MyProducts {get;set;}
  public AboutController()
       string searchquery='select Product_Code__c,name,price__c,imagename__c  from MyProduct__c '; 
       MyProducts= Database.query(searchquery); 
visual page:
<apex:page controller="AboutController"  >
    <apex:form >
      <apex:pageBlock title="Search Result"> 
             <apex:pageblockTable value="{!MyProducts}" var="a">               
                <apex:column value="{!a.ImageName__c}"/> 
                <apex:column value="{!a.Product_Code__c}"/> 
                <apex:column value="{!a.Name}"/> 
                <apex:column value="{!a.Price__c}"/>                
If i run by url: https://vnittest-dev-ed--c.ap5.visual.force.com/apex/about, It display 4 columns
But if run by Force.com Site url: https://vnittest2-developer-edition.ap5.force.com/demo1/about, it only display 2 columns: Product_Code__c,Name

Why can't get value of some colums in Custom Object?

I am getting the following error when validating step 6 of  the Project Create Reports and Dashboards for Sales and Marketing Managers.

The error is: 

Step not yet complete... here's what's wrong:
The 'Global Sales Dashboard' dashboard does not contain a component with the header 'Win Rates' that displays a table

I do have a component with the hearder Win Rates that displays a table:screenshot of dashboard with Win Rates table.

Thanks for any pointers on how to get by this.

Just a quick comment (correction): In the "Navigating and Customizing Salesforce" Module, under "Searching for Records", first sentence: "You" is used twice. Not sure where else to post needed corrections...