• nesh
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 5
    Likes Received
  • 0
    Likes Given
  • 65
    Questions
  • 31
    Replies
I HAVE ACCOUNT AND CONTACT RECORD DATA. UPDATE ACCOUNT FIELD TO CONTACT FIELD.HERE I DONT WANT TO WORKFLOW..I WANT TO UPDATE 20 FIELD ON CONTACT OBJECT  LIKE ADDRESS ,ZIPCODE,WEBSITE ETC.Account lookup field for contac.
MY TASK IS: WHEN UPDATE Createcontact__cCHECKBOX FIELD  ON CONTACT OBJECT-ALL 20 FIELD UPDATE FROM ACCOUNT TO CONTACT OBJECT.Createcontact__c (CHECK BOX FIELD ) IS A WORKFLOW FIELD UPDATE.. how to pull account field to on (Update)contact. field. please guide me
my code is :
trigger updatecontact1 on  Contact (after insert)
{
    Contact acc=Trigger.new[0];
    Contact aco=Trigger.old[0];
    account tt =new account();
   if(acc.Createcontact__c== TRUE && aco.Createcontact__c!= TRUE )
       {
      
       system.debug('@@'+aco.Createcontact__c);
        integer cont = [ select count()  from contact where accountid=:tt.id ];
        system.debug('@@'+cont);here i got zeo row.
         if (cont==1)
         {
        
          acc= [ select id,Address_1__c from Contact where accountid=:tt.id ];
          acc.Address_1__c=tt.Address_1__c;
          update acc;
          }
         
          }
          }
  • January 11, 2014
  • Like
  • 0

how to Calling Apex Class from List Custom Button.Please give ur idea

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

public with sharing class Trainingsurveylistbutton {
public List<training__c> t2;
public set<string> Set1;
public boolean pageblockCheck{set;get;}
//public List<training__c> l1 = New List<training__c>();
    public Trainingsurveylistbutton(ApexPages.StandardSetController controller) {
   
    t2 = new list <training__c>();
    t2=Controller.getSelected();
    system.debug('++++++++++T2::::'+t2);
    if(t2.size()<=0)
        {
       //for(training__c s1 : t2){
       //s1.addError('Please select atleast one record from list view you wish to update');
       // }
       ApexPages.Message errMsg = new ApexPages.Message(ApexPages.Severity.WARNING, 'Please select atleast one record from list view you wish to update');  
            ApexPages.addMessage(errMsg);

        }
        else{
  
      Here i am used set- to get all selected record id  . but i want to get all selected record field .. how to get selected record  under all field .Please give ur idea.i want to use those selected record field -below surveylist() method.i have marked red
            set1 = New set<string>();
           for(training__c ss : t2){
               system.debug('::::ss.Id::::'+ss);
               // Set1.add(ss.ID);
               system.debug('++++++++++set1'+set1);
            }

 
}
    }
    public void surveylist()
    {
    // Sweep training object for day 2 , 3 & 5th day survey
       //List <training__c> t1 = new list <training__c>();
       list <training_survey__c> ts2 = new list<training_survey__c>();
       t2 = [ select id,day1surveyflag__c,T__c, day3surveyflag__c, day5surveyflag__c from training__c];// where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true or T__c='Day 1' ];
      for(string lx : set1)
      {  
        system.debug('*********lx'+lx);
        
        training_survey__c ts = new training_survey__c();
        training__c tr = new training__c();
     
        integer ts1=[select count() from training_survey__c where Training__c =: lx];
        system.debug('**count'+ts1);
        if(ts1==1)
        {
        
          ts=[select id,Training__c,survey_type__c from training_survey__c where Training__c =: lx];
          
          system.debug('*************ts'+ts.survey_type__c);
               
              if(ts.Survey_Type__c == 'Day1') 
              {
                ts.sample__c = 'one day';
              }
          //   ts2.add(ts);
          }
          update ts;
           system.debug('*************ts'+ts.survey_type__c);

     //   if(ts2 != null )
     //              {
      //                  update ts2;  
      //             } 
        
        if (ts1==0)
                {    
                   ts.training__C = lx;
                   ts.Survey_Type__c = 'Day1';
                // }
                   ts2.add(ts); 
                   
               if(ts2 != null )
                  {
                        insert ts2;  
                   } 
                 }
            }
       }

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

please give your idea above code..

  • December 16, 2013
  • Like
  • 0

I have two object.Training and training survey...training record lookup relationship with training
survey.training object have training start date custom field...training survey have traning__c
lookup field.Traing survey have survey type custom field.
Process: if training start date --today+1,today+2,today+3--will send trainingsurvey email (day 1
or day 2 or day3 )to corresponding taining object record.else will send drop training survey.i
have set formula field check box..day 1 flag,day3,day5--whenever flag true -i have created
schedule process...apex class will insert survey type under traning survey object .i have created
workflow email alert -when will u insert survey type will send corresponding survey to corresponding records.

MY APEX LOGIC for schedule process.

global class MyTrainingSurveyProcess implements Schedulable
{
    global void execute(SchedulableContext SC)
    {
       // Sweep training object for day 2 , 3 & 5th day survey
       List <training__c> t1 = new list <training__c>();
       list <training_survey__c> ts2 = new list<training_survey__c>();
       t1 = [ select day1surveyflag__c, day3surveyflag__c, day5surveyflag__c from training__c where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true ];
       for(training__c tx : t1)
          {
             training_survey__c ts = new training_survey__c();
             ts.training__C = tx.id;
             if(tx.day1surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day1';
               }else
             if(tx.day3surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day3';
               }else
             if(tx.day5surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day5';
               }else
               {
                 ts.Survey_Type__c = 'Dropped';
               } 
             RecordType r = [Select id from Recordtype where sobjecttype = 'training_survey__c' and name= :ts.Survey_Type__c];
             ts.RecordTypeid = r.id;
             ts2.add(ts); 
          } 
        if(ts2 != null )
         {
           insert ts2;  
         }     
    }         
}
My requirement :
A)In case a past training survey was not created for a person and it is no longer within the 
timeframes specified..- will send training survey -when click list button.
B)If a Survey record has already been created for the specific Day, we just need to resend the 
existing survey record link..(purpose:survey was not filled by person within the 
timeframes specified)
Here i need manual list view button on training object.i want to have 4 buttons that represent each survey.when i click list button(day1,day3,day5,drop) cover above(A&B) two logic.
i know list button creation.
How to Calling Apex Class from List Custom Button?.Please give ur idea for Calling Apex Class from List Custom Button and how to cover above (A&B)two logic using apex class.Please give one example..

  • December 14, 2013
  • Like
  • 0

I have two object.Training and training survey...training record lookup relationship with training
survey.training object have training start date custom field...training survey have traning__c
lookup field.Traing survey have survey type custom field.
Process: if training start date --today+1,today+2,today+3--will send trainingsurvey email (day 1
or day 2 or day3 )to corresponding taining object record.else will send drop training survey.i
have set formula field check box..day 1 flag,day3,day5--whenever flag true -i have created
schedule process...apex class will insert survey type under traning survey object .i have created
workflow email alert -when will u insert survey type will send corresponding survey to corresponding records.

MY APEX LOGIC for schedule process.

global class MyTrainingSurveyProcess implements Schedulable
{
    global void execute(SchedulableContext SC)
    {
       // Sweep training object for day 2 , 3 & 5th day survey
       List <training__c> t1 = new list <training__c>();
       list <training_survey__c> ts2 = new list<training_survey__c>();
       t1 = [ select day1surveyflag__c, day3surveyflag__c, day5surveyflag__c from training__c where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true ];
       for(training__c tx : t1)
          {
             training_survey__c ts = new training_survey__c();
             ts.training__C = tx.id;
             if(tx.day1surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day1';
               }else
             if(tx.day3surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day3';
               }else
             if(tx.day5surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day5';
               }else
               {
                 ts.Survey_Type__c = 'Dropped';
               } 
             RecordType r = [Select id from Recordtype where sobjecttype = 'training_survey__c' and name= :ts.Survey_Type__c];
             ts.RecordTypeid = r.id;
             ts2.add(ts); 
          } 
        if(ts2 != null )
         {
           insert ts2;  
         }     
    }         
}
My requirement :
A)In case a past training survey was not created for a person and it is no longer within the
timeframes specified..- will send training survey -when click list button.
B)If a Survey record has already been created for the specific Day, we just need to resend the
existing survey record link..(purpose:survey was not filled by person within the
timeframes specified)
Here i need manual list view button on training object.i want to have 4 buttons that represent each survey.when i click list button(day1,day3,day5,drop) cover above(A&B) two logic.
i know list button creation.
How to Calling Apex Class from List Custom Button?.Please give ur idea for Calling Apex Class from List Custom Button and how to cover above (A&B)two logic using apex class.

  • December 14, 2013
  • Like
  • 0

How to use Trigger -below logic--: wheneverTraining object survey  flag true i want to insert field into Training survey object..and also insert record type ..please help me..

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

List <training__c> t1 = new list <training__c>();
       list <training_survey__c> ts2 = new list<training_survey__c>();
       t1 = [ select day1surveyflag__c, day3surveyflag__c, day5surveyflag__c from training__c where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true ];
       for(training__c tx : t1)
          { 
             training_survey__c ts = new training_survey__c();
             ts.training__C = tx.id;
             if(tx.day1surveyflag__c == true ) 
               {
                 ts.Survey_Type__c = 'Day1';
               }else
             if(tx.day3surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day3';
               }else
             if(tx.day5surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day5';
               }else
               {
                 ts.Survey_Type__c = 'Dropped';
               } 
             RecordType r = [Select id from Recordtype where sobjecttype = 'training_survey__c' and name= :ts.Survey_Type__c];
             ts.RecordTypeid = r.id;
             ts2.add(ts); 
          } 
        if(ts2 != null )
         {
           insert ts2;  
         }     

  • December 13, 2013
  • Like
  • 0

How to use Trigger -below logic--: wheneverTraining object survey  flag true i want to insert field into Training survey object..and also insert record type ..please help me..

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

List <training__c> t1 = new list <training__c>();
       list <training_survey__c> ts2 = new list<training_survey__c>();
       t1 = [ select day1surveyflag__c, day3surveyflag__c, day5surveyflag__c from training__c where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true ];
       for(training__c tx : t1)
          { 
             training_survey__c ts = new training_survey__c();
             ts.training__C = tx.id;
             if(tx.day1surveyflag__c == true ) 
               {
                 ts.Survey_Type__c = 'Day1';
               }else
             if(tx.day3surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day3';
               }else
             if(tx.day5surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day5';
               }else
               {
                 ts.Survey_Type__c = 'Dropped';
               } 
             RecordType r = [Select id from Recordtype where sobjecttype = 'training_survey__c' and name= :ts.Survey_Type__c];
             ts.RecordTypeid = r.id;
             ts2.add(ts); 
          } 
        if(ts2 != null )
         {
           insert ts2;  
         }     

  • December 13, 2013
  • Like
  • 0

How to use Trigger -below logic--: wheneverTraining object survey  flag true i want to insert field into Training survey object..and also insert record type ..please help me..

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

List <training__c> t1 = new list <training__c>();
       list <training_survey__c> ts2 = new list<training_survey__c>();
       t1 = [ select day1surveyflag__c, day3surveyflag__c, day5surveyflag__c from training__c where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true ];
       for(training__c tx : t1)
          { 
             training_survey__c ts = new training_survey__c();
             ts.training__C = tx.id;
             if(tx.day1surveyflag__c == true ) 
               {
                 ts.Survey_Type__c = 'Day1';
               }else
             if(tx.day3surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day3';
               }else
             if(tx.day5surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day5';
               }else
               {
                 ts.Survey_Type__c = 'Dropped';
               } 
             RecordType r = [Select id from Recordtype where sobjecttype = 'training_survey__c' and name= :ts.Survey_Type__c];
             ts.RecordTypeid = r.id;
             ts2.add(ts); 
          } 
        if(ts2 != null )
         {
           insert ts2;  
         }     

  • December 13, 2013
  • Like
  • 0

 When i click list view  button -selected records custom field are updated in corresponding records..Usong onclick javascript

My code :

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} //adds the proper code for inclusion of AJAX toolkit 
var url = parent.location.href; //string for the URL of the current page 
var records = {!GETRECORDIDS($ObjectType.Training__c)}; //grabs the Lead records that the user is requesting to update 
var updateRecords = []; //array for holding records that this code will ultimately update 

if (records[0] == null) {  

//if the button was clicked but there was no record selected 
alert

("Please select at least one record to update."); //alert the user that they didn't make a selection 
} else { //otherwise, there was a record selection 
for (var a=0; a<records.length; a++) { //for all records 
var update_Train = new sforce.SObject("Training__c"); //create a new sObject for storing updated record details 
update_Train.Id = records[a]; //set the Id of the selected Lead record 
update_Train.Training_Status__c= 'Pass'; or  update_Train.Status__c = true;
updateRecords.push(update_Train); 

result = sforce.connection.update(updateRecords); 
parent.location.href = url; //refresh the page 
}

Above code doesnt update record .When i click Please give ur idea when click  list button update or insert  the custom field - please help me.

  • December 13, 2013
  • Like
  • 0

When i click list view  button -selected records custom field are updated in corresponding records..Usong onclick javascript

My code :

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} //adds the proper code for inclusion of AJAX toolkit 
var url = parent.location.href; //string for the URL of the current page 
var records = {!GETRECORDIDS($ObjectType.Training__c)}; //grabs the Lead records that the user is requesting to update 
var updateRecords = []; //array for holding records that this code will ultimately update 

if (records[0] == null) {  

//if the button was clicked but there was no record selected 
alert

("Please select at least one record to update."); //alert the user that they didn't make a selection 
} else { //otherwise, there was a record selection 
for (var a=0; a<records.length; a++) { //for all records 
var update_Train = new sforce.SObject("Training__c"); //create a new sObject for storing updated record details 
update_Train.Id = records[a]; //set the Id of the selected Lead record 
update_Train.Training_Status__c= 'Pass'; or  update_Train.Status__c = true;
updateRecords.push(update_Train); 

result = sforce.connection.update(updateRecords); 
parent.location.href = url; //refresh the page 
}

Above code doesnt update record .When i click Please give ur idea when click  list button update or insert  the custom field - please help me.

  • December 13, 2013
  • Like
  • 0

I have got error :Error: Compiled formula is too big to execute (6,715 characters). Maximum size is 5,000 character.

My requirement is:

Calculate scores based on selection  checkbox:

Visualforce page:

        

     question               P - 0                       p--1                 p--2                 p--3             p--4

A                                  chechkbox           chechkbox

C

D

E

F

G

H

I

J

L                           chechkbox               chechkbox                                                   chechkbox

 

:(Sample for first question formula field name is A)

A=.IF(P0__c = true , 0 , 
   IF(p1__c = true , 1 , 
  IF(p2__c= true , 2 , 
   IF(p3__c= true , 3 , 
    IF(p4__c = true ,4 , null )))))

I have created  formula field  for  12 Questions (A to L) LIKE ABOVE

Then created  total formula field ---Total =A__c+B__c+C__c+D__c+E__c+F__c+G__c+H__c+I__c+J__c+K__c+L__c..

This is the my requirement . But i have got Error: Compiled formula is too big to execute (6,715 characters). Maximum size is 5,000 characters.How to reduce Compiled size in Formula field ..OR How to use this logic in apex code .Please give ur idea For this task.I dont want to work flow field update process. because i want to update existing record also..

  • December 12, 2013
  • Like
  • 0

How to call  apex class from List View Custom Button  ..my inside apex class code is here- how to use it...Please help me

INSIDE CLASS:
List <training__c> t1 = new list <training__c>();
       list <training_survey__c> ts2 = new list<training_survey__c>();
       t1 = [ select day1surveyflag__c, day3surveyflag__c, day5surveyflag__c from training__c where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true ];
       for(training__c tx : t1)
          {
             training_survey__c ts = new training_survey__c();
             ts.training__C = tx.id;
             if(tx.day1surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day1';
               }else
             if(tx.day3surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day3';
               }else
             if(tx.day5surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day5';
               }else
               {
                 ts.Survey_Type__c = 'Dropped';
               } 
             RecordType r = [Select id from Recordtype where sobjecttype = 'training_survey__c' and name= :ts.Survey_Type__c];
             ts.RecordTypeid = r.id;
             ts2.add(ts); 
          } 
        if(ts2 != null )
         {
           insert ts2;  
         }     

 

 

  • December 11, 2013
  • Like
  • 0

How to highlight a custom field based on condion( Highlight in RED if below 75% ).

custom field name:Total Grade.(data type :percentage )

my vf page code:

<apex:pageblockSection title="Total Grade">

<apex:outputField value="{!newapp.Total_grade_1__c}" styleclass="{!if((newapp.Total_grade_1__c<75), 'color:red', '')}" /

</apex:pageblockSection>

above code doesnt work. my custom field data type is percentage...Please help me.

  • December 10, 2013
  • Like
  • 0

How to highlight a custom field based on condion( Highlight in RED if below 75% ).

custom field name:Total Grade.(data type :percentage )

my vf page code:

<apex:pageblockSection title="Total Grade">

<apex:outputField value="{!newapp.Total_grade_1__c}" styleclass="{!if((newapp.Total_grade_1__c<75), 'color:red', '')}" /

</apex:pageblockSection>

above code doesnt work. my custom field data type is percentage...Please help me.

  • December 10, 2013
  • Like
  • 0

My apex class -only covered 36%.Please help me-get more coverage(above 75%).....

APEXCLASS:

 

global class populatevatimesheetrepository implements Schedulable
{
  public integer inscount=0;
  public integer updtcount=0;
  public integer rcnt;
  public string randomgen;
  Public Date mydate{get;set;}
  public String sdate {get;set;}
        
  global void execute(SchedulableContext SC)
  {
    
    list<VATimesheet__c> va1 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va2 = new list<VAtimesheetRepository__c>();
    list<VATimesheet__c> va3 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va4 = new list<VAtimesheetRepository__c>();
        
    //** random no logic
    
    integer va1count=[select count() from VATimesheet__c where Status__c='Processed' and ( BackUpID__c = NULL or Backupid__c = '' ) ];

below  red lines  are not coverd…..
    if (va1count > 0)
       
       { 
         system.debug('value of count:'+va1count);      
         DateTime dT = System.now();
         myDate = date.newinstance(dT.year(), dT.month(), dT.day());
         sdate = String.valueOf(myDate);
         do 
            {
                 system.debug('coming to calculate random number');
                 double d=math.random()*2;
                 randomgen=sdate+ '-' + string.valueof(d.intvalue());
                 system.debug('the random number value is:'+randomgen);
                 rcnt = [ select count() from vatimesheet__c where backupid__c = :randomgen];
             }
         while(rcnt > 0);
         
         va1=[select id,AccountId__c,AccountName__c,AcctID__c,Aname__c,BackUpID__c,BCRNo__c,BCRRecID__c,
                     Billed_Hrs__c,Contract_Hours__c,chrs__c,Job_type__c,OT_Hrs__c,VAId__c,Payrollno__c,
                     Payroll_status__c,srchstring__c,Status__c,TimeCardDate__c,Type__c,VA__c,VAName__c,
                     Vname__c from VATimesheet__c where Status__c='Processed' and (BackUpID__c=NULL or Backupid__c = '')];
         for(VATimesheet__c vt:va1)
            {
              system.debug('The backup id value is :' + randomgen);
              
              //***updating time sheet object
              vt.BackUpID__c=randomgen;
              va3.add(vt); 
              
              //** inserting into timesheet repository
               va2.add(new VAtimesheetRepository__c(AccountId__c=vt.AccountId__c,Aname__c=vt.Aname__c,BackUpID__c=vt.BackUpID__c,BCRNo__c=vt.BCRNo__c,
                      BCRRecID__c=vt.BCRRecID__c,Billed_Hrs__c=vt.Billed_Hrs__c,Contract_Hours__c=vt.Contract_Hours__c,Job_type__c=vt.Job_type__c,
                      OT_Hrs__c=vt.OT_Hrs__c,VAId__c=vt.VAId__c,Payrollno__c=vt.Payrollno__c,Payroll_status__c=vt.Payroll_status__c,
                      Status__c=vt.Status__c,TimeCardDate__c=vt.TimeCardDate__c,Type__c=vt.Type__c));
            }
         insert va2; 
         system.debug('the row is inserted');
         update va3;
         system.debug('the row is updated');
         savepoint sp=database.setsavepoint();         
         integer vtcnt = [ select count() from vatimesheet__C where backupid__c = :randomgen ];
         integer vtrcnt = [ select count() from vatimesheetrepository__C where backupid__c = :randomgen ];
                 
         try
           {
             system.assertequals(vtcnt,vtrcnt);
              
             } 
          catch(exception e)
            {
              database.rollback(sp);
             }
                       
                   
       }
     
  }    
}

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

testclass:

@isTest(seealldata=true)
private class VAtimesheetRepository1
{
  //*****************************************************************************
  //** this Test class will test the VAtimesheet and VAtimesheetRepository      *
  //*****************************************************************************
   public static String CRON_EXP = '0 0 0 22 5 ? 2020';
    
    
  Public static testmethod void m0()
    {
        account a1 = new account();
     a1.name = 'AA';
     insert a1;
         
     our_va__c v1 = new our_va__c();
     v1.name = 'v1';
     insert v1;
     
     contact c1= new contact();
     c1.LastName='cccccc';
     c1.Accountid=a1.id;
     c1.Primarycontact__c=true;
     insert c1;
         
     vatimesheet__c  v2 = new vatimesheet__c();
     v2.TimeCardDate__c= date.parse('8/10/2013'); 
     v2.Status__c='Processed';
     v2.Type__c='Working';
     v2.AccountId__c=a1.id;
     v2.VAId__c=v1.id;
     v2.OT_Hrs__c= 0; 
     v2.Billed_Hrs__c=5.0;
     v2.BackUpID__c=NULL;
     insert v2;
    
      
    VAtimesheetRepository__c v3= new VAtimesheetRepository__c();  
    insert v3;  
              
      String jobId = System.schedule('ScheduleApexClassTest', CRON_EXP, new populatevatimesheetrepository());
       CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
         //Verify the expressions are the same
        System.assertEquals(CRON_EXP,ct.CronExpression);
         //Verify the job has not run
        System.assertEquals(0,ct.TimesTriggered);
          //Verify the next time the job will run
        System.assertEquals('2020-05-22 00:00:00',
       String.valueOf(ct.NextFireTime));     
    
       } 
       
 }
  • December 05, 2013
  • Like
  • 0

My apex class -only covered 36%.Please help me-get more coverage(above 75%).....

APEXCLASS:

 

global class populatevatimesheetrepository implements Schedulable
{
  public integer inscount=0;
  public integer updtcount=0;
  public integer rcnt;
  public string randomgen;
  Public Date mydate{get;set;}
  public String sdate {get;set;}
        
  global void execute(SchedulableContext SC)
  {
    
    list<VATimesheet__c> va1 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va2 = new list<VAtimesheetRepository__c>();
    list<VATimesheet__c> va3 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va4 = new list<VAtimesheetRepository__c>();
        
    //** random no logic
    
    integer va1count=[select count() from VATimesheet__c where Status__c='Processed' and ( BackUpID__c = NULL or Backupid__c = '' ) ];

below  red lines  are not coverd…..
    if (va1count > 0)
       
       { 
         system.debug('value of count:'+va1count);      
         DateTime dT = System.now();
         myDate = date.newinstance(dT.year(), dT.month(), dT.day());
         sdate = String.valueOf(myDate);
         do 
            {
                 system.debug('coming to calculate random number');
                 double d=math.random()*2;
                 randomgen=sdate+ '-' + string.valueof(d.intvalue());
                 system.debug('the random number value is:'+randomgen);
                 rcnt = [ select count() from vatimesheet__c where backupid__c = :randomgen];
             }
         while(rcnt > 0);
         
         va1=[select id,AccountId__c,AccountName__c,AcctID__c,Aname__c,BackUpID__c,BCRNo__c,BCRRecID__c,
                     Billed_Hrs__c,Contract_Hours__c,chrs__c,Job_type__c,OT_Hrs__c,VAId__c,Payrollno__c,
                     Payroll_status__c,srchstring__c,Status__c,TimeCardDate__c,Type__c,VA__c,VAName__c,
                     Vname__c from VATimesheet__c where Status__c='Processed' and (BackUpID__c=NULL or Backupid__c = '')];
         for(VATimesheet__c vt:va1)
            {
              system.debug('The backup id value is :' + randomgen);
              
              //***updating time sheet object
              vt.BackUpID__c=randomgen;
              va3.add(vt); 
              
              //** inserting into timesheet repository
               va2.add(new VAtimesheetRepository__c(AccountId__c=vt.AccountId__c,Aname__c=vt.Aname__c,BackUpID__c=vt.BackUpID__c,BCRNo__c=vt.BCRNo__c,
                      BCRRecID__c=vt.BCRRecID__c,Billed_Hrs__c=vt.Billed_Hrs__c,Contract_Hours__c=vt.Contract_Hours__c,Job_type__c=vt.Job_type__c,
                      OT_Hrs__c=vt.OT_Hrs__c,VAId__c=vt.VAId__c,Payrollno__c=vt.Payrollno__c,Payroll_status__c=vt.Payroll_status__c,
                      Status__c=vt.Status__c,TimeCardDate__c=vt.TimeCardDate__c,Type__c=vt.Type__c));
            }
         insert va2; 
         system.debug('the row is inserted');
         update va3;
         system.debug('the row is updated');
         savepoint sp=database.setsavepoint();         
         integer vtcnt = [ select count() from vatimesheet__C where backupid__c = :randomgen ];
         integer vtrcnt = [ select count() from vatimesheetrepository__C where backupid__c = :randomgen ];
                 
         try
           {
             system.assertequals(vtcnt,vtrcnt);
              
             } 
          catch(exception e)
            {
              database.rollback(sp);
             }
                       
                   
       }
     
  }    
}

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

testclass:

@isTest(seealldata=true)
private class VAtimesheetRepository1
{
  //*****************************************************************************
  //** this Test class will test the VAtimesheet and VAtimesheetRepository      *
  //*****************************************************************************
   public static String CRON_EXP = '0 0 0 22 5 ? 2020';
    
    
  Public static testmethod void m0()
    {
        account a1 = new account();
     a1.name = 'AA';
     insert a1;
         
     our_va__c v1 = new our_va__c();
     v1.name = 'v1';
     insert v1;
     
     contact c1= new contact();
     c1.LastName='cccccc';
     c1.Accountid=a1.id;
     c1.Primarycontact__c=true;
     insert c1;
         
     vatimesheet__c  v2 = new vatimesheet__c();
     v2.TimeCardDate__c= date.parse('8/10/2013'); 
     v2.Status__c='Processed';
     v2.Type__c='Working';
     v2.AccountId__c=a1.id;
     v2.VAId__c=v1.id;
     v2.OT_Hrs__c= 0; 
     v2.Billed_Hrs__c=5.0;
     v2.BackUpID__c=NULL;
     insert v2;
    
      
    VAtimesheetRepository__c v3= new VAtimesheetRepository__c();  
    insert v3;  
              
      String jobId = System.schedule('ScheduleApexClassTest', CRON_EXP, new populatevatimesheetrepository());
       CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
         //Verify the expressions are the same
        System.assertEquals(CRON_EXP,ct.CronExpression);
         //Verify the job has not run
        System.assertEquals(0,ct.TimesTriggered);
          //Verify the next time the job will run
        System.assertEquals('2020-05-22 00:00:00',
       String.valueOf(ct.NextFireTime));     
    
       } 
       
 }
  • December 05, 2013
  • Like
  • 0

My apex class -only covered 36%.Please help me-get more coverage(above 75%).....

APEXCLASS:

 

global class populatevatimesheetrepository implements Schedulable
{
  public integer inscount=0;
  public integer updtcount=0;
  public integer rcnt;
  public string randomgen;
  Public Date mydate{get;set;}
  public String sdate {get;set;}
        
  global void execute(SchedulableContext SC)
  {
    
    list<VATimesheet__c> va1 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va2 = new list<VAtimesheetRepository__c>();
    list<VATimesheet__c> va3 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va4 = new list<VAtimesheetRepository__c>();
        
    //** random no logic
    
    integer va1count=[select count() from VATimesheet__c where Status__c='Processed' and ( BackUpID__c = NULL or Backupid__c = '' ) ];

below  red lines  are not coverd…..
    if (va1count > 0)
       
       { 
         system.debug('value of count:'+va1count);      
         DateTime dT = System.now();
         myDate = date.newinstance(dT.year(), dT.month(), dT.day());
         sdate = String.valueOf(myDate);
         do 
            {
                 system.debug('coming to calculate random number');
                 double d=math.random()*2;
                 randomgen=sdate+ '-' + string.valueof(d.intvalue());
                 system.debug('the random number value is:'+randomgen);
                 rcnt = [ select count() from vatimesheet__c where backupid__c = :randomgen];
             }
         while(rcnt > 0);
         
         va1=[select id,AccountId__c,AccountName__c,AcctID__c,Aname__c,BackUpID__c,BCRNo__c,BCRRecID__c,
                     Billed_Hrs__c,Contract_Hours__c,chrs__c,Job_type__c,OT_Hrs__c,VAId__c,Payrollno__c,
                     Payroll_status__c,srchstring__c,Status__c,TimeCardDate__c,Type__c,VA__c,VAName__c,
                     Vname__c from VATimesheet__c where Status__c='Processed' and (BackUpID__c=NULL or Backupid__c = '')];
         for(VATimesheet__c vt:va1)
            {
              system.debug('The backup id value is :' + randomgen);
              
              //***updating time sheet object
              vt.BackUpID__c=randomgen;
              va3.add(vt); 
              
              //** inserting into timesheet repository
               va2.add(new VAtimesheetRepository__c(AccountId__c=vt.AccountId__c,Aname__c=vt.Aname__c,BackUpID__c=vt.BackUpID__c,BCRNo__c=vt.BCRNo__c,
                      BCRRecID__c=vt.BCRRecID__c,Billed_Hrs__c=vt.Billed_Hrs__c,Contract_Hours__c=vt.Contract_Hours__c,Job_type__c=vt.Job_type__c,
                      OT_Hrs__c=vt.OT_Hrs__c,VAId__c=vt.VAId__c,Payrollno__c=vt.Payrollno__c,Payroll_status__c=vt.Payroll_status__c,
                      Status__c=vt.Status__c,TimeCardDate__c=vt.TimeCardDate__c,Type__c=vt.Type__c));
            }
         insert va2; 
         system.debug('the row is inserted');
         update va3;
         system.debug('the row is updated');
         savepoint sp=database.setsavepoint();         
         integer vtcnt = [ select count() from vatimesheet__C where backupid__c = :randomgen ];
         integer vtrcnt = [ select count() from vatimesheetrepository__C where backupid__c = :randomgen ];
                 
         try
           {
             system.assertequals(vtcnt,vtrcnt);
              
             } 
          catch(exception e)
            {
              database.rollback(sp);
             }
                       
                   
       }
     
  }    
}

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

testclass:

@isTest(seealldata=true)
private class VAtimesheetRepository1
{
  //*****************************************************************************
  //** this Test class will test the VAtimesheet and VAtimesheetRepository      *
  //*****************************************************************************
   public static String CRON_EXP = '0 0 0 22 5 ? 2020';
    
    
  Public static testmethod void m0()
    {
        account a1 = new account();
     a1.name = 'AA';
     insert a1;
         
     our_va__c v1 = new our_va__c();
     v1.name = 'v1';
     insert v1;
     
     contact c1= new contact();
     c1.LastName='cccccc';
     c1.Accountid=a1.id;
     c1.Primarycontact__c=true;
     insert c1;
         
     vatimesheet__c  v2 = new vatimesheet__c();
     v2.TimeCardDate__c= date.parse('8/10/2013'); 
     v2.Status__c='Processed';
     v2.Type__c='Working';
     v2.AccountId__c=a1.id;
     v2.VAId__c=v1.id;
     v2.OT_Hrs__c= 0; 
     v2.Billed_Hrs__c=5.0;
     v2.BackUpID__c=NULL;
     insert v2;
    
      
    VAtimesheetRepository__c v3= new VAtimesheetRepository__c();  
    insert v3;  
              
      String jobId = System.schedule('ScheduleApexClassTest', CRON_EXP, new populatevatimesheetrepository());
       CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
         //Verify the expressions are the same
        System.assertEquals(CRON_EXP,ct.CronExpression);
         //Verify the job has not run
        System.assertEquals(0,ct.TimesTriggered);
          //Verify the next time the job will run
        System.assertEquals('2020-05-22 00:00:00',
       String.valueOf(ct.NextFireTime));     
    
       } 
       
 }
  • December 05, 2013
  • Like
  • 0

My apex class -only covered 36%.Please help me-get more coverage(above 75%).....

APEXCLASS:

global class populatevatimesheetrepository implements Schedulable
{
  public integer inscount=0;
  public integer updtcount=0;
  public integer rcnt;
  public string randomgen;
  Public Date mydate{get;set;}
  public String sdate {get;set;}
        
  global void execute(SchedulableContext SC)
  {
    
    list<VATimesheet__c> va1 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va2 = new list<VAtimesheetRepository__c>();
    list<VATimesheet__c> va3 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va4 = new list<VAtimesheetRepository__c>();
        
    //** random no logic
    
    integer va1count=[select count() from VATimesheet__c where Status__c='Processed' and ( BackUpID__c = NULL or Backupid__c = '' ) ];
    if (va1count > 0)
       {
         do 
            {
                 double d=math.random()*2;
                 DateTime dT = System.now();
                 myDate = date.newinstance(dT.year(), dT.month(), dT.day());
                 sdate = String.valueOf(myDate);
                 randomgen=sdate+ '-' + string.valueof(d.intvalue());
                 system.debug('the random number value is:'+randomgen);
                 rcnt = [ select count() from vatimesheet__c where backupid__c = :randomgen];
                 if (rcnt==0)
                     {
                       break;
                      }
            }
         while(rcnt == 0);
         
         va1=[select id,AccountId__c,AccountName__c,AcctID__c,Aname__c,BackUpID__c,BCRNo__c,BCRRecID__c,
                     Billed_Hrs__c,Contract_Hours__c,chrs__c,Job_type__c,OT_Hrs__c,VAId__c,Payrollno__c,
                     Payroll_status__c,srchstring__c,Status__c,TimeCardDate__c,Type__c,VA__c,VAName__c,
                     Vname__c from VATimesheet__c where Status__c='Processed' and BackUpID__c=NULL];
         for(VATimesheet__c vt:va1)
            {
              system.debug('The backup id value is :' + randomgen);
              
              //***updating time sheet object
              vt.BackUpID__c=randomgen;
              va3.add(vt); 
              
              //** inserting into timesheet repository
               va2.add(new VAtimesheetRepository__c(AccountId__c=vt.AccountId__c,Aname__c=vt.Aname__c,BackUpID__c=vt.BackUpID__c,BCRNo__c=vt.BCRNo__c,
                      BCRRecID__c=vt.BCRRecID__c,Billed_Hrs__c=vt.Billed_Hrs__c,Contract_Hours__c=vt.Contract_Hours__c,Job_type__c=vt.Job_type__c,
                      OT_Hrs__c=vt.OT_Hrs__c,VAId__c=vt.VAId__c,Payrollno__c=vt.Payrollno__c,Payroll_status__c=vt.Payroll_status__c,
                      Status__c=vt.Status__c,TimeCardDate__c=vt.TimeCardDate__c,Type__c=vt.Type__c));
            }
         insert va2; 
         update va3;
         savepoint sp=database.setsavepoint(); 
         
         integer vtcnt = [ select count() from vatimesheet__C where backupid__c = :randomgen ];
         integer vtrcnt = [ select count() from vatimesheetrepository__C where backupid__c = :randomgen ];
                 
         try
           {
             system.assertequals(vtcnt,vtrcnt);
              
             } 
          catch(exception e)
            {
              database.rollback(sp);
             }
                       
                   
       }
     
  }    
}

 TEST CLASS:

@isTest(seealldata=true)
private class VAtimesheetRepository1
{
  //*****************************************************************************
  //** this Test class will test the VAtimesheet and VAtimesheetRepository      *
  //*****************************************************************************
   public static String CRON_EXP = '0 0 0 22 5 ? 2020';
    
    
  Public static testmethod void m0()
    {
        account a1 = new account();
     a1.name = 'AA';
     insert a1;
         
     our_va__c v1 = new our_va__c();
     v1.name = 'v1';
     insert v1;
     
     contact c1= new contact();
     c1.LastName='cccccc';
     c1.Accountid=a1.id;
     c1.Primarycontact__c=true;
     insert c1;
         
     vatimesheet__c  v2 = new vatimesheet__c();
     v2.TimeCardDate__c= date.parse('8/10/2013'); 
     v2.Status__c='Processed';
     v2.Type__c='Working';
     v2.AccountId__c=a1.id;
     v2.VAId__c=v1.id;
     v2.OT_Hrs__c= 0; 
     v2.Billed_Hrs__c=5.0;
     v2.BackUpID__c=NULL;
     insert v2;
    
      
    VAtimesheetRepository__c v3= new VAtimesheetRepository__c();  
    insert v3;  
              
      String jobId = System.schedule('ScheduleApexClassTest', CRON_EXP, new populatevatimesheetrepository());
       CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
         //Verify the expressions are the same
        System.assertEquals(CRON_EXP,ct.CronExpression);
         //Verify the job has not run
        System.assertEquals(0,ct.TimesTriggered);
          //Verify the next time the job will run
        System.assertEquals('2020-05-22 00:00:00',
       String.valueOf(ct.NextFireTime));     
    
       } 
       
 }
  • December 03, 2013
  • Like
  • 0

My apex class -only covered 36%.Please help me-get more coverage(above 75%).....

APEXCLASS:

global class populatevatimesheetrepository implements Schedulable
{
  public integer inscount=0;
  public integer updtcount=0;
  public integer rcnt;
  public string randomgen;
  Public Date mydate{get;set;}
  public String sdate {get;set;}
        
  global void execute(SchedulableContext SC)
  {
    
    list<VATimesheet__c> va1 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va2 = new list<VAtimesheetRepository__c>();
    list<VATimesheet__c> va3 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va4 = new list<VAtimesheetRepository__c>();
        
    //** random no logic
    
    integer va1count=[select count() from VATimesheet__c where Status__c='Processed' and ( BackUpID__c = NULL or Backupid__c = '' ) ];
    if (va1count > 0)
       {
         do 
            {
                 double d=math.random()*2;
                 DateTime dT = System.now();
                 myDate = date.newinstance(dT.year(), dT.month(), dT.day());
                 sdate = String.valueOf(myDate);
                 randomgen=sdate+ '-' + string.valueof(d.intvalue());
                 system.debug('the random number value is:'+randomgen);
                 rcnt = [ select count() from vatimesheet__c where backupid__c = :randomgen];
                 if (rcnt==0)
                     {
                       break;
                      }
            }
         while(rcnt == 0);
         
         va1=[select id,AccountId__c,AccountName__c,AcctID__c,Aname__c,BackUpID__c,BCRNo__c,BCRRecID__c,
                     Billed_Hrs__c,Contract_Hours__c,chrs__c,Job_type__c,OT_Hrs__c,VAId__c,Payrollno__c,
                     Payroll_status__c,srchstring__c,Status__c,TimeCardDate__c,Type__c,VA__c,VAName__c,
                     Vname__c from VATimesheet__c where Status__c='Processed' and BackUpID__c=NULL];
         for(VATimesheet__c vt:va1)
            {
              system.debug('The backup id value is :' + randomgen);
              
              //***updating time sheet object
              vt.BackUpID__c=randomgen;
              va3.add(vt); 
              
              //** inserting into timesheet repository
               va2.add(new VAtimesheetRepository__c(AccountId__c=vt.AccountId__c,Aname__c=vt.Aname__c,BackUpID__c=vt.BackUpID__c,BCRNo__c=vt.BCRNo__c,
                      BCRRecID__c=vt.BCRRecID__c,Billed_Hrs__c=vt.Billed_Hrs__c,Contract_Hours__c=vt.Contract_Hours__c,Job_type__c=vt.Job_type__c,
                      OT_Hrs__c=vt.OT_Hrs__c,VAId__c=vt.VAId__c,Payrollno__c=vt.Payrollno__c,Payroll_status__c=vt.Payroll_status__c,
                      Status__c=vt.Status__c,TimeCardDate__c=vt.TimeCardDate__c,Type__c=vt.Type__c));
            }
         insert va2; 
         update va3;
         savepoint sp=database.setsavepoint(); 
         
         integer vtcnt = [ select count() from vatimesheet__C where backupid__c = :randomgen ];
         integer vtrcnt = [ select count() from vatimesheetrepository__C where backupid__c = :randomgen ];
                 
         try
           {
             system.assertequals(vtcnt,vtrcnt);
              
             } 
          catch(exception e)
            {
              database.rollback(sp);
             }
                       
                   
       }
     
  }    
}

 TEST CLASS:

@isTest(seealldata=true)
private class VAtimesheetRepository1
{
  //*****************************************************************************
  //** this Test class will test the VAtimesheet and VAtimesheetRepository      *
  //*****************************************************************************
   public static String CRON_EXP = '0 0 0 22 5 ? 2020';
    
    
  Public static testmethod void m0()
    {
        account a1 = new account();
     a1.name = 'AA';
     insert a1;
         
     our_va__c v1 = new our_va__c();
     v1.name = 'v1';
     insert v1;
     
     contact c1= new contact();
     c1.LastName='cccccc';
     c1.Accountid=a1.id;
     c1.Primarycontact__c=true;
     insert c1;
         
     vatimesheet__c  v2 = new vatimesheet__c();
     v2.TimeCardDate__c= date.parse('8/10/2013'); 
     v2.Status__c='Processed';
     v2.Type__c='Working';
     v2.AccountId__c=a1.id;
     v2.VAId__c=v1.id;
     v2.OT_Hrs__c= 0; 
     v2.Billed_Hrs__c=5.0;
     v2.BackUpID__c=NULL;
     insert v2;
    
      
    VAtimesheetRepository__c v3= new VAtimesheetRepository__c();  
    insert v3;  
              
      String jobId = System.schedule('ScheduleApexClassTest', CRON_EXP, new populatevatimesheetrepository());
       CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
         //Verify the expressions are the same
        System.assertEquals(CRON_EXP,ct.CronExpression);
         //Verify the job has not run
        System.assertEquals(0,ct.TimesTriggered);
          //Verify the next time the job will run
        System.assertEquals('2020-05-22 00:00:00',
       String.valueOf(ct.NextFireTime));     
    
       } 
       
 }
  • December 03, 2013
  • Like
  • 0

Display multi radio button on same line in visualforce page.Is it possible to make multi-radio buttons alignment like displayed in the following LINK. I would like to display questions as multi-radio button.Please help me.

https://docs.google.com/a/tandture.com/document/d/1hpJTrR0-UAyRJpPGvdeuKybZZW2BnGYLIy6yEcy43Nk/edit

  • December 01, 2013
  • Like
  • 0

Display multi radio button on same line in visualforce page.Is it possible to make multi-radio buttons alignment like displayed in the following LINK. I would like to display questions as multi-radio button.Please help me.

https://docs.google.com/a/tandture.com/document/d/1hpJTrR0-UAyRJpPGvdeuKybZZW2BnGYLIy6yEcy43Nk/edit

  • December 01, 2013
  • Like
  • 0

Is it possible to make multi-radio buttons alignment like displayed in the following MSword. I would like to display questions as multi-radio button

Tell us how well the following statements apply to your exec team.

 

 

Strongly Disagree

Disagree

Neither Agree or Disagree

Agree

Strongly Agree

Sets proper expectation of the company goals

 

 

 

 

 

   

Takes time to listen to me

 

 

 

 

 

   

Gives me fair reviews

 

 

 

 

 

   

Reasonable expectations of my work

 

 

 

 

 

   

 

 

 

 

 

 

   

Prepared to train me whenever necessary

 

 

 

 

 

s in a visualforce page.PLEASE HELP ME.

  • December 01, 2013
  • Like
  • 1

Hi

    Create a New Record on Custom Object when field on Standard Object (OPPORTUNITY)changes.

when opportunity object field changes (opp.record_type__c=='One timedonations' &&  opp.StageName=='pledged' && opp.Probability==100).its automatically create a New Record on Custom Object -name :One timedonations'.when i update opp object that also update on corresponding record on onetimedonation custom object. please correct my code.

 

 

trigger createonedonationrecord on Opportunity ( after insert,AFTER UPDATE)
{
  Opportunity opp=Trigger.new[0];
 
    if( opp.record_type__c=='One timedonations' &&  opp.StageName=='pledged' && opp.Probability==decimal.valueof(100) && OPP.npe03__Recurring_Donation__c==NULL)
    {         
    
              OneTimedonation__c  td1=new OneTimedonation__c();
              
              integer tds1=[select count() from OneTimedonation__c where Is_one_time_donation_created__c=false];
              if(tds1 ==0)
              {
              //td1=[select id,Organization__c,amount__c,Donation_Types__c from OneTimedonation__c where Is_one_time_donation_created__c=false];
              td1.Is_one_time_donation_created__c=True;
              td1.amount__c =opp.Amount;
              td1.Organization__c=opp.Accountid;
              td1.Campaign__c=opp.Campaignid;
              td1.Donation_Types__c=opp.Donation_type__c;
             // tdl.onetimedonationdone__c=true;
              insert td1;
              }
         if(trigger.isupdate)
            {
           
               // OneTimedonation__c  td1=new OneTimedonation__c();
              integer cntac1 =[select count() from OneTimedonation__c where Organization__c=:opp.Accountid];
              system.debug('count'+cntac1);
              if(cntac1 ==1)
              {
              td1=[select id,Organization__c from OneTimedonation__c where Organization__c=:opp.Accountid];
              td1.amount__c =opp.Amount;
              td1.Organization__c=opp.Accountid;
              td1.Campaign__c=opp.Campaignid;
              td1.Donation_Types__c=opp.Donation_type__c;
              update td1;
            
              }
           }
          
          
     }
 }

  • November 10, 2013
  • Like
  • 1

Hi

 when i save the test class IN SFDC.i got error name:java.lang.reflect.InvocationTargetException . already i file the case..how to overcome thi issue. please help me.

  • November 09, 2013
  • Like
  • 1

Hi

 when i save the test class i got error name:java.lang.reflect.InvocationTargetException . already i file the case..how to overcome thi issue. please help me.

  • November 09, 2013
  • Like
  • 1

Hi,

I want to create a CUSTOM clone button which will clone the record in edit mode and user want can change some value and save the record.Please give your knowledge here

  • October 18, 2013
  • Like
  • 1

how to Calling Apex Class from List Custom Button.Please give ur idea

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

public with sharing class Trainingsurveylistbutton {
public List<training__c> t2;
public set<string> Set1;
public boolean pageblockCheck{set;get;}
//public List<training__c> l1 = New List<training__c>();
    public Trainingsurveylistbutton(ApexPages.StandardSetController controller) {
   
    t2 = new list <training__c>();
    t2=Controller.getSelected();
    system.debug('++++++++++T2::::'+t2);
    if(t2.size()<=0)
        {
       //for(training__c s1 : t2){
       //s1.addError('Please select atleast one record from list view you wish to update');
       // }
       ApexPages.Message errMsg = new ApexPages.Message(ApexPages.Severity.WARNING, 'Please select atleast one record from list view you wish to update');  
            ApexPages.addMessage(errMsg);

        }
        else{
  
      Here i am used set- to get all selected record id  . but i want to get all selected record field .. how to get selected record  under all field .Please give ur idea.i want to use those selected record field -below surveylist() method.i have marked red
            set1 = New set<string>();
           for(training__c ss : t2){
               system.debug('::::ss.Id::::'+ss);
               // Set1.add(ss.ID);
               system.debug('++++++++++set1'+set1);
            }

 
}
    }
    public void surveylist()
    {
    // Sweep training object for day 2 , 3 & 5th day survey
       //List <training__c> t1 = new list <training__c>();
       list <training_survey__c> ts2 = new list<training_survey__c>();
       t2 = [ select id,day1surveyflag__c,T__c, day3surveyflag__c, day5surveyflag__c from training__c];// where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true or T__c='Day 1' ];
      for(string lx : set1)
      {  
        system.debug('*********lx'+lx);
        
        training_survey__c ts = new training_survey__c();
        training__c tr = new training__c();
     
        integer ts1=[select count() from training_survey__c where Training__c =: lx];
        system.debug('**count'+ts1);
        if(ts1==1)
        {
        
          ts=[select id,Training__c,survey_type__c from training_survey__c where Training__c =: lx];
          
          system.debug('*************ts'+ts.survey_type__c);
               
              if(ts.Survey_Type__c == 'Day1') 
              {
                ts.sample__c = 'one day';
              }
          //   ts2.add(ts);
          }
          update ts;
           system.debug('*************ts'+ts.survey_type__c);

     //   if(ts2 != null )
     //              {
      //                  update ts2;  
      //             } 
        
        if (ts1==0)
                {    
                   ts.training__C = lx;
                   ts.Survey_Type__c = 'Day1';
                // }
                   ts2.add(ts); 
                   
               if(ts2 != null )
                  {
                        insert ts2;  
                   } 
                 }
            }
       }

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

please give your idea above code..

  • December 16, 2013
  • Like
  • 0

I have two object.Training and training survey...training record lookup relationship with training
survey.training object have training start date custom field...training survey have traning__c
lookup field.Traing survey have survey type custom field.
Process: if training start date --today+1,today+2,today+3--will send trainingsurvey email (day 1
or day 2 or day3 )to corresponding taining object record.else will send drop training survey.i
have set formula field check box..day 1 flag,day3,day5--whenever flag true -i have created
schedule process...apex class will insert survey type under traning survey object .i have created
workflow email alert -when will u insert survey type will send corresponding survey to corresponding records.

MY APEX LOGIC for schedule process.

global class MyTrainingSurveyProcess implements Schedulable
{
    global void execute(SchedulableContext SC)
    {
       // Sweep training object for day 2 , 3 & 5th day survey
       List <training__c> t1 = new list <training__c>();
       list <training_survey__c> ts2 = new list<training_survey__c>();
       t1 = [ select day1surveyflag__c, day3surveyflag__c, day5surveyflag__c from training__c where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true ];
       for(training__c tx : t1)
          {
             training_survey__c ts = new training_survey__c();
             ts.training__C = tx.id;
             if(tx.day1surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day1';
               }else
             if(tx.day3surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day3';
               }else
             if(tx.day5surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day5';
               }else
               {
                 ts.Survey_Type__c = 'Dropped';
               } 
             RecordType r = [Select id from Recordtype where sobjecttype = 'training_survey__c' and name= :ts.Survey_Type__c];
             ts.RecordTypeid = r.id;
             ts2.add(ts); 
          } 
        if(ts2 != null )
         {
           insert ts2;  
         }     
    }         
}
My requirement :
A)In case a past training survey was not created for a person and it is no longer within the 
timeframes specified..- will send training survey -when click list button.
B)If a Survey record has already been created for the specific Day, we just need to resend the 
existing survey record link..(purpose:survey was not filled by person within the 
timeframes specified)
Here i need manual list view button on training object.i want to have 4 buttons that represent each survey.when i click list button(day1,day3,day5,drop) cover above(A&B) two logic.
i know list button creation.
How to Calling Apex Class from List Custom Button?.Please give ur idea for Calling Apex Class from List Custom Button and how to cover above (A&B)two logic using apex class.Please give one example..

  • December 14, 2013
  • Like
  • 0

How to use Trigger -below logic--: wheneverTraining object survey  flag true i want to insert field into Training survey object..and also insert record type ..please help me..

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

List <training__c> t1 = new list <training__c>();
       list <training_survey__c> ts2 = new list<training_survey__c>();
       t1 = [ select day1surveyflag__c, day3surveyflag__c, day5surveyflag__c from training__c where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true ];
       for(training__c tx : t1)
          { 
             training_survey__c ts = new training_survey__c();
             ts.training__C = tx.id;
             if(tx.day1surveyflag__c == true ) 
               {
                 ts.Survey_Type__c = 'Day1';
               }else
             if(tx.day3surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day3';
               }else
             if(tx.day5surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day5';
               }else
               {
                 ts.Survey_Type__c = 'Dropped';
               } 
             RecordType r = [Select id from Recordtype where sobjecttype = 'training_survey__c' and name= :ts.Survey_Type__c];
             ts.RecordTypeid = r.id;
             ts2.add(ts); 
          } 
        if(ts2 != null )
         {
           insert ts2;  
         }     

  • December 13, 2013
  • Like
  • 0

 When i click list view  button -selected records custom field are updated in corresponding records..Usong onclick javascript

My code :

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} //adds the proper code for inclusion of AJAX toolkit 
var url = parent.location.href; //string for the URL of the current page 
var records = {!GETRECORDIDS($ObjectType.Training__c)}; //grabs the Lead records that the user is requesting to update 
var updateRecords = []; //array for holding records that this code will ultimately update 

if (records[0] == null) {  

//if the button was clicked but there was no record selected 
alert

("Please select at least one record to update."); //alert the user that they didn't make a selection 
} else { //otherwise, there was a record selection 
for (var a=0; a<records.length; a++) { //for all records 
var update_Train = new sforce.SObject("Training__c"); //create a new sObject for storing updated record details 
update_Train.Id = records[a]; //set the Id of the selected Lead record 
update_Train.Training_Status__c= 'Pass'; or  update_Train.Status__c = true;
updateRecords.push(update_Train); 

result = sforce.connection.update(updateRecords); 
parent.location.href = url; //refresh the page 
}

Above code doesnt update record .When i click Please give ur idea when click  list button update or insert  the custom field - please help me.

  • December 13, 2013
  • Like
  • 0

How to call  apex class from List View Custom Button  ..my inside apex class code is here- how to use it...Please help me

INSIDE CLASS:
List <training__c> t1 = new list <training__c>();
       list <training_survey__c> ts2 = new list<training_survey__c>();
       t1 = [ select day1surveyflag__c, day3surveyflag__c, day5surveyflag__c from training__c where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true ];
       for(training__c tx : t1)
          {
             training_survey__c ts = new training_survey__c();
             ts.training__C = tx.id;
             if(tx.day1surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day1';
               }else
             if(tx.day3surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day3';
               }else
             if(tx.day5surveyflag__c == true )
               {
                 ts.Survey_Type__c = 'Day5';
               }else
               {
                 ts.Survey_Type__c = 'Dropped';
               } 
             RecordType r = [Select id from Recordtype where sobjecttype = 'training_survey__c' and name= :ts.Survey_Type__c];
             ts.RecordTypeid = r.id;
             ts2.add(ts); 
          } 
        if(ts2 != null )
         {
           insert ts2;  
         }     

 

 

  • December 11, 2013
  • Like
  • 0

How to highlight a custom field based on condion( Highlight in RED if below 75% ).

custom field name:Total Grade.(data type :percentage )

my vf page code:

<apex:pageblockSection title="Total Grade">

<apex:outputField value="{!newapp.Total_grade_1__c}" styleclass="{!if((newapp.Total_grade_1__c<75), 'color:red', '')}" /

</apex:pageblockSection>

above code doesnt work. my custom field data type is percentage...Please help me.

  • December 10, 2013
  • Like
  • 0

How to highlight a custom field based on condion( Highlight in RED if below 75% ).

custom field name:Total Grade.(data type :percentage )

my vf page code:

<apex:pageblockSection title="Total Grade">

<apex:outputField value="{!newapp.Total_grade_1__c}" styleclass="{!if((newapp.Total_grade_1__c<75), 'color:red', '')}" /

</apex:pageblockSection>

above code doesnt work. my custom field data type is percentage...Please help me.

  • December 10, 2013
  • Like
  • 0

My apex class -only covered 36%.Please help me-get more coverage(above 75%).....

APEXCLASS:

 

global class populatevatimesheetrepository implements Schedulable
{
  public integer inscount=0;
  public integer updtcount=0;
  public integer rcnt;
  public string randomgen;
  Public Date mydate{get;set;}
  public String sdate {get;set;}
        
  global void execute(SchedulableContext SC)
  {
    
    list<VATimesheet__c> va1 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va2 = new list<VAtimesheetRepository__c>();
    list<VATimesheet__c> va3 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va4 = new list<VAtimesheetRepository__c>();
        
    //** random no logic
    
    integer va1count=[select count() from VATimesheet__c where Status__c='Processed' and ( BackUpID__c = NULL or Backupid__c = '' ) ];

below  red lines  are not coverd…..
    if (va1count > 0)
       
       { 
         system.debug('value of count:'+va1count);      
         DateTime dT = System.now();
         myDate = date.newinstance(dT.year(), dT.month(), dT.day());
         sdate = String.valueOf(myDate);
         do 
            {
                 system.debug('coming to calculate random number');
                 double d=math.random()*2;
                 randomgen=sdate+ '-' + string.valueof(d.intvalue());
                 system.debug('the random number value is:'+randomgen);
                 rcnt = [ select count() from vatimesheet__c where backupid__c = :randomgen];
             }
         while(rcnt > 0);
         
         va1=[select id,AccountId__c,AccountName__c,AcctID__c,Aname__c,BackUpID__c,BCRNo__c,BCRRecID__c,
                     Billed_Hrs__c,Contract_Hours__c,chrs__c,Job_type__c,OT_Hrs__c,VAId__c,Payrollno__c,
                     Payroll_status__c,srchstring__c,Status__c,TimeCardDate__c,Type__c,VA__c,VAName__c,
                     Vname__c from VATimesheet__c where Status__c='Processed' and (BackUpID__c=NULL or Backupid__c = '')];
         for(VATimesheet__c vt:va1)
            {
              system.debug('The backup id value is :' + randomgen);
              
              //***updating time sheet object
              vt.BackUpID__c=randomgen;
              va3.add(vt); 
              
              //** inserting into timesheet repository
               va2.add(new VAtimesheetRepository__c(AccountId__c=vt.AccountId__c,Aname__c=vt.Aname__c,BackUpID__c=vt.BackUpID__c,BCRNo__c=vt.BCRNo__c,
                      BCRRecID__c=vt.BCRRecID__c,Billed_Hrs__c=vt.Billed_Hrs__c,Contract_Hours__c=vt.Contract_Hours__c,Job_type__c=vt.Job_type__c,
                      OT_Hrs__c=vt.OT_Hrs__c,VAId__c=vt.VAId__c,Payrollno__c=vt.Payrollno__c,Payroll_status__c=vt.Payroll_status__c,
                      Status__c=vt.Status__c,TimeCardDate__c=vt.TimeCardDate__c,Type__c=vt.Type__c));
            }
         insert va2; 
         system.debug('the row is inserted');
         update va3;
         system.debug('the row is updated');
         savepoint sp=database.setsavepoint();         
         integer vtcnt = [ select count() from vatimesheet__C where backupid__c = :randomgen ];
         integer vtrcnt = [ select count() from vatimesheetrepository__C where backupid__c = :randomgen ];
                 
         try
           {
             system.assertequals(vtcnt,vtrcnt);
              
             } 
          catch(exception e)
            {
              database.rollback(sp);
             }
                       
                   
       }
     
  }    
}

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

testclass:

@isTest(seealldata=true)
private class VAtimesheetRepository1
{
  //*****************************************************************************
  //** this Test class will test the VAtimesheet and VAtimesheetRepository      *
  //*****************************************************************************
   public static String CRON_EXP = '0 0 0 22 5 ? 2020';
    
    
  Public static testmethod void m0()
    {
        account a1 = new account();
     a1.name = 'AA';
     insert a1;
         
     our_va__c v1 = new our_va__c();
     v1.name = 'v1';
     insert v1;
     
     contact c1= new contact();
     c1.LastName='cccccc';
     c1.Accountid=a1.id;
     c1.Primarycontact__c=true;
     insert c1;
         
     vatimesheet__c  v2 = new vatimesheet__c();
     v2.TimeCardDate__c= date.parse('8/10/2013'); 
     v2.Status__c='Processed';
     v2.Type__c='Working';
     v2.AccountId__c=a1.id;
     v2.VAId__c=v1.id;
     v2.OT_Hrs__c= 0; 
     v2.Billed_Hrs__c=5.0;
     v2.BackUpID__c=NULL;
     insert v2;
    
      
    VAtimesheetRepository__c v3= new VAtimesheetRepository__c();  
    insert v3;  
              
      String jobId = System.schedule('ScheduleApexClassTest', CRON_EXP, new populatevatimesheetrepository());
       CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
         //Verify the expressions are the same
        System.assertEquals(CRON_EXP,ct.CronExpression);
         //Verify the job has not run
        System.assertEquals(0,ct.TimesTriggered);
          //Verify the next time the job will run
        System.assertEquals('2020-05-22 00:00:00',
       String.valueOf(ct.NextFireTime));     
    
       } 
       
 }
  • December 05, 2013
  • Like
  • 0

My apex class -only covered 36%.Please help me-get more coverage(above 75%).....

APEXCLASS:

 

global class populatevatimesheetrepository implements Schedulable
{
  public integer inscount=0;
  public integer updtcount=0;
  public integer rcnt;
  public string randomgen;
  Public Date mydate{get;set;}
  public String sdate {get;set;}
        
  global void execute(SchedulableContext SC)
  {
    
    list<VATimesheet__c> va1 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va2 = new list<VAtimesheetRepository__c>();
    list<VATimesheet__c> va3 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va4 = new list<VAtimesheetRepository__c>();
        
    //** random no logic
    
    integer va1count=[select count() from VATimesheet__c where Status__c='Processed' and ( BackUpID__c = NULL or Backupid__c = '' ) ];

below  red lines  are not coverd…..
    if (va1count > 0)
       
       { 
         system.debug('value of count:'+va1count);      
         DateTime dT = System.now();
         myDate = date.newinstance(dT.year(), dT.month(), dT.day());
         sdate = String.valueOf(myDate);
         do 
            {
                 system.debug('coming to calculate random number');
                 double d=math.random()*2;
                 randomgen=sdate+ '-' + string.valueof(d.intvalue());
                 system.debug('the random number value is:'+randomgen);
                 rcnt = [ select count() from vatimesheet__c where backupid__c = :randomgen];
             }
         while(rcnt > 0);
         
         va1=[select id,AccountId__c,AccountName__c,AcctID__c,Aname__c,BackUpID__c,BCRNo__c,BCRRecID__c,
                     Billed_Hrs__c,Contract_Hours__c,chrs__c,Job_type__c,OT_Hrs__c,VAId__c,Payrollno__c,
                     Payroll_status__c,srchstring__c,Status__c,TimeCardDate__c,Type__c,VA__c,VAName__c,
                     Vname__c from VATimesheet__c where Status__c='Processed' and (BackUpID__c=NULL or Backupid__c = '')];
         for(VATimesheet__c vt:va1)
            {
              system.debug('The backup id value is :' + randomgen);
              
              //***updating time sheet object
              vt.BackUpID__c=randomgen;
              va3.add(vt); 
              
              //** inserting into timesheet repository
               va2.add(new VAtimesheetRepository__c(AccountId__c=vt.AccountId__c,Aname__c=vt.Aname__c,BackUpID__c=vt.BackUpID__c,BCRNo__c=vt.BCRNo__c,
                      BCRRecID__c=vt.BCRRecID__c,Billed_Hrs__c=vt.Billed_Hrs__c,Contract_Hours__c=vt.Contract_Hours__c,Job_type__c=vt.Job_type__c,
                      OT_Hrs__c=vt.OT_Hrs__c,VAId__c=vt.VAId__c,Payrollno__c=vt.Payrollno__c,Payroll_status__c=vt.Payroll_status__c,
                      Status__c=vt.Status__c,TimeCardDate__c=vt.TimeCardDate__c,Type__c=vt.Type__c));
            }
         insert va2; 
         system.debug('the row is inserted');
         update va3;
         system.debug('the row is updated');
         savepoint sp=database.setsavepoint();         
         integer vtcnt = [ select count() from vatimesheet__C where backupid__c = :randomgen ];
         integer vtrcnt = [ select count() from vatimesheetrepository__C where backupid__c = :randomgen ];
                 
         try
           {
             system.assertequals(vtcnt,vtrcnt);
              
             } 
          catch(exception e)
            {
              database.rollback(sp);
             }
                       
                   
       }
     
  }    
}

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

testclass:

@isTest(seealldata=true)
private class VAtimesheetRepository1
{
  //*****************************************************************************
  //** this Test class will test the VAtimesheet and VAtimesheetRepository      *
  //*****************************************************************************
   public static String CRON_EXP = '0 0 0 22 5 ? 2020';
    
    
  Public static testmethod void m0()
    {
        account a1 = new account();
     a1.name = 'AA';
     insert a1;
         
     our_va__c v1 = new our_va__c();
     v1.name = 'v1';
     insert v1;
     
     contact c1= new contact();
     c1.LastName='cccccc';
     c1.Accountid=a1.id;
     c1.Primarycontact__c=true;
     insert c1;
         
     vatimesheet__c  v2 = new vatimesheet__c();
     v2.TimeCardDate__c= date.parse('8/10/2013'); 
     v2.Status__c='Processed';
     v2.Type__c='Working';
     v2.AccountId__c=a1.id;
     v2.VAId__c=v1.id;
     v2.OT_Hrs__c= 0; 
     v2.Billed_Hrs__c=5.0;
     v2.BackUpID__c=NULL;
     insert v2;
    
      
    VAtimesheetRepository__c v3= new VAtimesheetRepository__c();  
    insert v3;  
              
      String jobId = System.schedule('ScheduleApexClassTest', CRON_EXP, new populatevatimesheetrepository());
       CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
         //Verify the expressions are the same
        System.assertEquals(CRON_EXP,ct.CronExpression);
         //Verify the job has not run
        System.assertEquals(0,ct.TimesTriggered);
          //Verify the next time the job will run
        System.assertEquals('2020-05-22 00:00:00',
       String.valueOf(ct.NextFireTime));     
    
       } 
       
 }
  • December 05, 2013
  • Like
  • 0

My apex class -only covered 36%.Please help me-get more coverage(above 75%).....

APEXCLASS:

 

global class populatevatimesheetrepository implements Schedulable
{
  public integer inscount=0;
  public integer updtcount=0;
  public integer rcnt;
  public string randomgen;
  Public Date mydate{get;set;}
  public String sdate {get;set;}
        
  global void execute(SchedulableContext SC)
  {
    
    list<VATimesheet__c> va1 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va2 = new list<VAtimesheetRepository__c>();
    list<VATimesheet__c> va3 = new list<VATimesheet__c>();
    list<VAtimesheetRepository__c> va4 = new list<VAtimesheetRepository__c>();
        
    //** random no logic
    
    integer va1count=[select count() from VATimesheet__c where Status__c='Processed' and ( BackUpID__c = NULL or Backupid__c = '' ) ];

below  red lines  are not coverd…..
    if (va1count > 0)
       
       { 
         system.debug('value of count:'+va1count);      
         DateTime dT = System.now();
         myDate = date.newinstance(dT.year(), dT.month(), dT.day());
         sdate = String.valueOf(myDate);
         do 
            {
                 system.debug('coming to calculate random number');
                 double d=math.random()*2;
                 randomgen=sdate+ '-' + string.valueof(d.intvalue());
                 system.debug('the random number value is:'+randomgen);
                 rcnt = [ select count() from vatimesheet__c where backupid__c = :randomgen];
             }
         while(rcnt > 0);
         
         va1=[select id,AccountId__c,AccountName__c,AcctID__c,Aname__c,BackUpID__c,BCRNo__c,BCRRecID__c,
                     Billed_Hrs__c,Contract_Hours__c,chrs__c,Job_type__c,OT_Hrs__c,VAId__c,Payrollno__c,
                     Payroll_status__c,srchstring__c,Status__c,TimeCardDate__c,Type__c,VA__c,VAName__c,
                     Vname__c from VATimesheet__c where Status__c='Processed' and (BackUpID__c=NULL or Backupid__c = '')];
         for(VATimesheet__c vt:va1)
            {
              system.debug('The backup id value is :' + randomgen);
              
              //***updating time sheet object
              vt.BackUpID__c=randomgen;
              va3.add(vt); 
              
              //** inserting into timesheet repository
               va2.add(new VAtimesheetRepository__c(AccountId__c=vt.AccountId__c,Aname__c=vt.Aname__c,BackUpID__c=vt.BackUpID__c,BCRNo__c=vt.BCRNo__c,
                      BCRRecID__c=vt.BCRRecID__c,Billed_Hrs__c=vt.Billed_Hrs__c,Contract_Hours__c=vt.Contract_Hours__c,Job_type__c=vt.Job_type__c,
                      OT_Hrs__c=vt.OT_Hrs__c,VAId__c=vt.VAId__c,Payrollno__c=vt.Payrollno__c,Payroll_status__c=vt.Payroll_status__c,
                      Status__c=vt.Status__c,TimeCardDate__c=vt.TimeCardDate__c,Type__c=vt.Type__c));
            }
         insert va2; 
         system.debug('the row is inserted');
         update va3;
         system.debug('the row is updated');
         savepoint sp=database.setsavepoint();         
         integer vtcnt = [ select count() from vatimesheet__C where backupid__c = :randomgen ];
         integer vtrcnt = [ select count() from vatimesheetrepository__C where backupid__c = :randomgen ];
                 
         try
           {
             system.assertequals(vtcnt,vtrcnt);
              
             } 
          catch(exception e)
            {
              database.rollback(sp);
             }
                       
                   
       }
     
  }    
}

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

testclass:

@isTest(seealldata=true)
private class VAtimesheetRepository1
{
  //*****************************************************************************
  //** this Test class will test the VAtimesheet and VAtimesheetRepository      *
  //*****************************************************************************
   public static String CRON_EXP = '0 0 0 22 5 ? 2020';
    
    
  Public static testmethod void m0()
    {
        account a1 = new account();
     a1.name = 'AA';
     insert a1;
         
     our_va__c v1 = new our_va__c();
     v1.name = 'v1';
     insert v1;
     
     contact c1= new contact();
     c1.LastName='cccccc';
     c1.Accountid=a1.id;
     c1.Primarycontact__c=true;
     insert c1;
         
     vatimesheet__c  v2 = new vatimesheet__c();
     v2.TimeCardDate__c= date.parse('8/10/2013'); 
     v2.Status__c='Processed';
     v2.Type__c='Working';
     v2.AccountId__c=a1.id;
     v2.VAId__c=v1.id;
     v2.OT_Hrs__c= 0; 
     v2.Billed_Hrs__c=5.0;
     v2.BackUpID__c=NULL;
     insert v2;
    
      
    VAtimesheetRepository__c v3= new VAtimesheetRepository__c();  
    insert v3;  
              
      String jobId = System.schedule('ScheduleApexClassTest', CRON_EXP, new populatevatimesheetrepository());
       CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
         //Verify the expressions are the same
        System.assertEquals(CRON_EXP,ct.CronExpression);
         //Verify the job has not run
        System.assertEquals(0,ct.TimesTriggered);
          //Verify the next time the job will run
        System.assertEquals('2020-05-22 00:00:00',
       String.valueOf(ct.NextFireTime));     
    
       } 
       
 }
  • December 05, 2013
  • Like
  • 0

Is it possible to make multi-radio buttons alignment like displayed in the following MSword. I would like to display questions as multi-radio button

Tell us how well the following statements apply to your exec team.

 

 

Strongly Disagree

Disagree

Neither Agree or Disagree

Agree

Strongly Agree

Sets proper expectation of the company goals

 

 

 

 

 

   

Takes time to listen to me

 

 

 

 

 

   

Gives me fair reviews

 

 

 

 

 

   

Reasonable expectations of my work

 

 

 

 

 

   

 

 

 

 

 

 

   

Prepared to train me whenever necessary

 

 

 

 

 

s in a visualforce page.PLEASE HELP ME.

  • December 01, 2013
  • Like
  • 1

I am having a picklist field Name -(donationtype )with values Vehicle,money,shoe

Based on the value selected by the user, I want to hide another pageblock section on VF page.I am using action supportand rerender and render. but its not working 

Can someone pls help me with the code.

VF PAGE:

<apex:page standardController="Pickup_Donation__c" extensions="PickupDonationcont" showheader="false" id="page" >
<table style="width: 100%;" >
<tr>
<td align="center" >
<apex:image height="128" width="1002" url="{!URLFOR($Resource.webheader)}"/>
</td>
</tr>
</table>
<apex:form >
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Submit" action="{!save}" />
<apex:commandButton value="cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Personal details" columns="2" >
<apex:inputfield required="true" label="First Name" value="{!Pickup_Donation__c.First_Name__c}" id="vn" />
<apex:inputfield required="true" label="Email" value="{!Pickup_Donation__c.Email__c}" id="vln2" />
<apex:inputfield required="true" label="Last Name" value="{!Pickup_Donation__c.Last_Name__c}" id="vln" />
<apex:inputfield required="true" label="Phone" value="{!Pickup_Donation__c.Phone__c}" id="vln1" />
<apex:inputfield label="Company Name" value="{!Pickup_Donation__c.Company_Name__c}" id="v1" />
</apex:pageBlockSection>
<apex:pageBlockSection title="Communication Info" columns="2" >
<apex:inputfield required="true" label="Street" value="{!Pickup_Donation__c.Street__c}" id="v2" /><br></br>
<apex:inputfield required="true" label="State/Province" value="{!Pickup_Donation__c.State_Province__c}" id="v3" /><br></br>
<apex:inputfield required="true" label="City" value="{!Pickup_Donation__c.City__c}" id="v43" /><br></br>
<apex:inputfield required="true" label="Zip/Postal Code" value="{!Pickup_Donation__c.Zip_Postal_Code__c}" id="v4" />
</apex:pageBlockSection>

<apex:pageBlockSection title="Donation Info" id="section1">

<apex:inputfield label="Donationtype" value="{!Pickup_Donation__c.Donation_type__c}" >
<apex:actionSupport event="onchange" reRender="section2"/>
</apex:inputField>


</apex:pageBlockSection>
<apex:outputPanel id="section2">
<apex:pageBlockSection title="Vehicles Info" rendered="{!Pickup_Donation__c.Donation_type__c == 'Vehicle'}" >
<apex:inputfield label="Vehicles Types" value="{!Pickup_Donation__c.Vehicles_Types__c}" id="textpop" />

</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
<table>
<tr>
<td align="center" >
<apex:image height="128" width="1032" url="{!URLFOR($Resource.footer)}"/>
</td>
</tr>
</table>

</apex:page>

 

  • November 28, 2013
  • Like
  • 0

Hi

    Create a New Record on Custom Object when field on Standard Object (OPPORTUNITY)changes.

when opportunity object field changes (opp.record_type__c=='One timedonations' &&  opp.StageName=='pledged' && opp.Probability==100).its automatically create a New Record on Custom Object -name :One timedonations'.when i update opp object that also update on corresponding record on onetimedonation custom object. please correct my code.

 

 

trigger createonedonationrecord on Opportunity ( after insert,AFTER UPDATE)
{
  Opportunity opp=Trigger.new[0];
 
    if( opp.record_type__c=='One timedonations' &&  opp.StageName=='pledged' && opp.Probability==decimal.valueof(100) && OPP.npe03__Recurring_Donation__c==NULL)
    {         
    
              OneTimedonation__c  td1=new OneTimedonation__c();
              
              integer tds1=[select count() from OneTimedonation__c where Is_one_time_donation_created__c=false];
              if(tds1 ==0)
              {
              //td1=[select id,Organization__c,amount__c,Donation_Types__c from OneTimedonation__c where Is_one_time_donation_created__c=false];
              td1.Is_one_time_donation_created__c=True;
              td1.amount__c =opp.Amount;
              td1.Organization__c=opp.Accountid;
              td1.Campaign__c=opp.Campaignid;
              td1.Donation_Types__c=opp.Donation_type__c;
             // tdl.onetimedonationdone__c=true;
              insert td1;
              }
         if(trigger.isupdate)
            {
           
               // OneTimedonation__c  td1=new OneTimedonation__c();
              integer cntac1 =[select count() from OneTimedonation__c where Organization__c=:opp.Accountid];
              system.debug('count'+cntac1);
              if(cntac1 ==1)
              {
              td1=[select id,Organization__c from OneTimedonation__c where Organization__c=:opp.Accountid];
              td1.amount__c =opp.Amount;
              td1.Organization__c=opp.Accountid;
              td1.Campaign__c=opp.Campaignid;
              td1.Donation_Types__c=opp.Donation_type__c;
              update td1;
            
              }
           }
          
          
     }
 }

  • November 10, 2013
  • Like
  • 0

i want to connect the salesforce to mandrill .all emails from the(sfdc) system will go out with mandrill app.

  • October 15, 2013
  • Like
  • 0