• SFD Salesforce
  • NEWBIE
  • 0 Points
  • Member since 2012

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

Hi All,

 

My requirement ,  how  to update the cases tab of  the field values update  for my chatter display in salesforce by using salesforce chatter. ple guidance the given requirement  with following steps

 

 

cheers

 

Pradeep P

Hi All,

 

How to install the Project /Issue Management in saleforce. by using appexchange .can any body help another way to install

the project /Issue Management .wht purpose and wht usage.

 

 

cheers

 

Pradeep.p

Hi all,

 

can help me test case of  my trigger .

 

This is trigger code,

 

 

global class Monthly{

public static void ValAdd()//Set<Id> InquiryId
{

List<Inquiry__c> Inquiry= [SELECT KPIInquiryContent__c,KPIInquiryContent__r.Account__c,CommodityName__c,ModifyDate__c,Status__c from Inquiry__c ];
{
Inquiry__c Fr= Inquiry[0];
Date startDate=fr.ModifyDate__c.toStartOfMonth();
Date endDate=fr.ModifyDate__c.toStartOfMonth().addMonths(1);

LIST<AggregateResult> countmonth=[SELECT count(KPIInquiryContent__c) coun from Inquiry__c where KPIInquiryContent__r.Account__c=:fr.KPIInquiryContent__r.Account__c and ModifyDate__c >= :startDate AND ModifyDate__c < :endDate and PayoffObject__c=:'○' and Status__c IN('対応中' ,'対応完了')];
//LIST<AggregateResult> calmonth=[Select CALENDAR_MONTH(WorkDate__c), count(ImportCount__c) icount from WorkResultsMonth__c where Account_Name__c=:acname GROUP BY CALENDAR_MONTH(WorkDate__c)];
LIST<AggregateResult> calmonth=[Select count(ImportCount__c) icount from WorkResultsMonth__c where WorkDate__c >= :startDate and WorkDate__c < :endDate and Account_Name__c=:fr.KPIInquiryContent__r.Account__c];

List<KPIAccident__c> acc= [SELECT Date__c,MonthlyGeneratedCount__c,MonthlyPPM__c from KPIAccident__c where Account_Name__c=:fr.KPIInquiryContent__r.Account__c and Date__c >= :startDate and Date__c < :endDate]; //
if(!acc.isEmpty() )
{

KPIAccident__c accupdate = acc[0];
Integer totalcountmonth=Integer.Valueof(countmonth[0].get('coun'));

accupdate.MonthlyGeneratedCount__c=totalcountmonth;

Integer totalmonthwork= Integer.Valueof(calmonth[0].get('icount'));
accupdate.MonthlyPPM__c=((totalmonthwork/totalcountmonth)*1000000);
update accupdate;
}else
{
KPIAccident__c kpi = new KPIAccident__c();
List<KPIAccident__c> ToUpdate = new List<KPIAccident__c>();
kpi.Date__c=fr.ModifyDate__c;
kpi.Account__c=fr.KPIInquiryContent__r.Account__c;
kpi.itemname__c= fr.CommodityName__c;

Integer totalcountmonths=Integer.Valueof(countmonth[0].get('coun'));
kpi.MonthlyGeneratedCount__c=totalcountmonths;
Integer totalmonthworks= Integer.Valueof(calmonth[0].get('icount'));

kpi.MonthlyPPM__c=((totalmonthworks/totalcountmonths)*1000000);
ToUpdate.add(kpi);
insert ToUpdate;

}
}
}}

 

 

 

 

my test case code is:

 

static testMethod void testAMethod1()
{
Test.startTest();
Account a2 = new Account();
a2.name='pradeep';
insert a2;
Inquiry__c f1=new Inquiry__c(CommodityName__c='pradeep',ModifyDate__c=date.parse('03/09/2012'),Status__c ='good');
insert f1;
List<KPIAccident__c> ac2=[SELECT Date__c,MonthlyGeneratedCount__c,MonthlyPPM__c from KPIAccident__c];

if(ac2.isEmpty())
{

KPIAccident__c m5=ac2[0];
m5.MonthlyGeneratedCount__c= 129;
m5.MonthlyPPM__c=2563;
//m5.Date__c=f1.ModifyDate__c;
insert m5;
}
else
{
List<KPIAccident__c> listEt = new List<KPIAccident__c>();
KPIAccident__c d1=new KPIAccident__c ();
d1.MonthlyGeneratedCount__c=145;
d1.MonthlyPPM__c=2569;
listEt.add(d1);
try
{
insert listEt;
}
catch(Exception e){}
Test.stopTest();

}
}
82 }

 

my trigger is:

 

trigger AddValue_to_Accident on Inquiry__c (after insert,after update)

{

Monthly.ValAdd();
}

 

 

 

 

 

The above red mark not coverage of my test case of trigger. The tese case was written but it should be coverage 61%.The red mark data not covered.  pls help me my test case of trigger..

 

 

If my  test case in build of trigger. it should be covered in 65% but an error is

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FBR_AddValue_to_Accident: execution of AfterInsert caused by: System.ListException: List index out of bounds: 0 Class.FBR_InquiryMonthly.ValAdd: line 38, column 1 Trigger.FBR_AddValue_to_Accident: line 5, column 1: []. 

 

can any help me  test case of trigger and solution of error.

 

Cheers

Pradeep Kumar.p

 

 

 

Hi,

 

This My trigger class,

 

global class FBR_ApexScheduleMonthClass Implements Schedulable
{
global void execute(SchedulableContext sc)
{
ValAdd();
}
public static void ValAdd()//Set<Id> InquiryId
{

List<FBR_Inquiry__c> Inquiry= [SELECT KPIInquiryContent__c,CommodityName__c,ModifyDate__c,Status__c from FBR_Inquiry__c ];
{
FBR_Inquiry__c FBR= Inquiry[0];
Date startDate=FBR.ModifyDate__c.toStartOfMonth();
Date endDate=FBR.ModifyDate__c.toStartOfMonth().addMonths(1);

LIST<AggregateResult> countmonth=[SELECT count(KPIInquiryContent__c) coun from FBR_Inquiry__c where ModifyDate__c >= :startDate AND ModifyDate__c < :endDate and PayoffObject__c=:'○' and Status__c IN('対応中' ,'対応完了')];
//LIST<AggregateResult> calmonth=[Select CALENDAR_MONTH(WorkDate__c), count(ImportCount__c) icount from WorkResultsMonth__c where Account_Name__c=:acname GROUP BY CALENDAR_MONTH(WorkDate__c)];
LIST<AggregateResult> calmonth=[Select count(ImportCount__c) icount from WorkResultsMonth__c where WorkDate__c >= :startDate and WorkDate__c < :endDate ];

List<KPIAccident__c> acc= [SELECT MonthlyGeneratedCount__c,MonthlyPPM__c from KPIAccident__c ];
if(!acc.isEmpty() )
{

KPIAccident__c accupdate = acc[0];
Integer totalcountmonth=Integer.Valueof(countmonth[0].get('coun'));

accupdate.MonthlyGeneratedCount__c=totalcountmonth;

Integer totalmonthwork= Integer.Valueof(calmonth[0].get('icount'));
accupdate.MonthlyPPM__c=(totalmonthwork/totalcountmonth*1000000);
update accupdate;
}else
{
KPIAccident__c kpi = new KPIAccident__c();
List<KPIAccident__c> ToUpdate = new List<KPIAccident__c>();
// kpi.Date__c=FBR.ModifyDate__c;
//kpi.Account__c=FBR.KPIInquiryContent__r.Account__c;
// kpi.itemname__c= FBR.CommodityName__c;

Integer totalcountmonths=Integer.Valueof(countmonth[0].get('coun'));
kpi.MonthlyGeneratedCount__c=totalcountmonths;
Integer totalmonthworks= Integer.Valueof(calmonth[0].get('icount'));

kpi.MonthlyPPM__c=(totalmonthworks/totalcountmonths*1000000);
ToUpdate.add(kpi);
insert ToUpdate;

}
}
} }

 

 

test case of trigger monthly

 

 

mytest case

 

 

@isTest(SeeAllData=true)
public class FBR_InquiryMonthlyTest
{


public static testMethod void testAMethod1(){
//FBR_ApexScheduleMonthClass f1=new FBR_ApexScheduleMonthClass ();
try
{
Test.startTest();

FBR_ApexScheduleMonthClass.ValAdd();

 

WorkResultsMonth__c f2=new WorkResultsMonth__c ();
f2.name='Test';
//2.ImportCount=15;

f2.ImportCount__c=100;
insert f2;

LIST<FBR_Inquiry__c> cc=new List<FBR_Inquiry__c>();
Date startDate=date.parse('9/09/2012');
Date endDate=date.parse('19/09/2012');

FBR_Inquiry__c m1=new FBR_Inquiry__c();
m1.CommodityName__c='rakuten123';
m1.ModifyDate__c=date.parse('07/09/2012');
m1.KPIInquiryContent__c='one';
cc.add(m1);
insert cc;
List<KPIAccident__c > ss=new List<KPIAccident__c >();
integer dTotalForAll = 12;
integer TotalCounts=251;


KPIAccident__c m2= new KPIAccident__c();
m2.Name='rakuten123' ;

Integer totalcountmonth=dTotalForAll;
m2.MonthlyGeneratedCount__c=totalcountmonth;
Integer totalmonthwork=TotalCounts;
m2.MonthlyPPM__c=(totalmonthwork/totalcountmonth*1000000);

insert ss;


KPIAccident__c kpi = new KPIAccident__c();

// kpi.Date__c=FBR.ModifyDate__c;
//kpi.Account__c=FBR.KPIInquiryContent__r.Account__c;
// kpi.itemname__c= FBR.CommodityName__c;

Integer totalcountmonths=dTotalForAll;
kpi.MonthlyGeneratedCount__c=m2.MonthlyGeneratedCount__c;
Integer totalmonthworks= TotalCounts;

kpi.MonthlyPPM__c=m2.MonthlyPPM__c;

insert kpi;

}
catch(Exception e){}
Test.stopTest();
}


}

 

The above Red mark is not Covering the my Test case.Now i covered test 57%. can any one help me the else condition of the test case.

 

cheers

Pradeep kumar.p

 

global class Monthly{
 
    public  static void ValAdd()//Set<Id> InquiryId
  {  
  
List<Inquiry__c> Inquiry= [SELECT KPIInquiryContent__c,KPIInquiryContent__r.Account__c,CommodityName__c,ModifyDate__c,Status__c from Inquiry__c  ];
{
Inquiry__c Fr= Inquiry[0];
Date startDate=fr.ModifyDate__c.toStartOfMonth();
Date endDate=fr.ModifyDate__c.toStartOfMonth().addMonths(1);
 
LIST<AggregateResult> countmonth=[SELECT count(KPIInquiryContent__c) coun from Inquiry__c where KPIInquiryContent__r.Account__c=:fr.KPIInquiryContent__r.Account__c and ModifyDate__c >= :startDate AND ModifyDate__c < :endDate and PayoffObject__c=:'○' and Status__c IN('対応中' ,'対応完了')];
 //LIST<AggregateResult> calmonth=[Select CALENDAR_MONTH(WorkDate__c), count(ImportCount__c) icount from WorkResultsMonth__c where Account_Name__c=:acname GROUP BY CALENDAR_MONTH(WorkDate__c)];
LIST<AggregateResult> calmonth=[Select count(ImportCount__c) icount from WorkResultsMonth__c where WorkDate__c >= :startDate and WorkDate__c < :endDate and Account_Name__c=:fr.KPIInquiryContent__r.Account__c];
 
List<KPIAccident__c> acc= [SELECT Date__c,MonthlyGeneratedCount__c,MonthlyPPM__c from KPIAccident__c where  Account_Name__c=:fr.KPIInquiryContent__r.Account__c and Date__c >= :startDate and Date__c < :endDate]; //     
if(!acc.isEmpty() )
      {
          
          KPIAccident__c accupdate = acc[0];         
          Integer totalcountmonth=Integer.Valueof(countmonth[0].get('coun')); 
          
          accupdate.MonthlyGeneratedCount__c=totalcountmonth;   
         
          Integer totalmonthwork= Integer.Valueof(calmonth[0].get('icount'));
          accupdate.MonthlyPPM__c=((totalmonthwork/totalcountmonth)*1000000);
          update accupdate;
      }else 
      {
         KPIAccident__c kpi = new KPIAccident__c();
         List<KPIAccident__c> ToUpdate = new List<KPIAccident__c>(); 
         kpi.Date__c=fr.ModifyDate__c;         
          kpi.Account__c=fr.KPIInquiryContent__r.Account__c;         
         kpi.itemname__c= fr.CommodityName__c;     
         
         Integer totalcountmonths=Integer.Valueof(countmonth[0].get('coun'));
         kpi.MonthlyGeneratedCount__c=totalcountmonths; 
         Integer totalmonthworks= Integer.Valueof(calmonth[0].get('icount'));
                    
         kpi.MonthlyPPM__c=((totalmonthworks/totalcountmonths)*1000000);
         ToUpdate.add(kpi);
         insert ToUpdate;
 
}
 }}
Pls help me apex scheduler class create  depending upon above code .
cheers
Pradeep