• NNR
  • NEWBIE
  • 79 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 57
    Questions
  • 42
    Replies
global class UserLogoutEvents implements Database.batchable<String>, Database.Stateful{
  global list<Document> doc=new List<Document>();
  Blob logoutcontentFile;
 
 global Iterable<String> start(Database.BatchableContext BC){   
                    doc=[SELECT id,body,BodyLength,ContentType,CreatedDate,Description,DeveloperName,Name,Type FROM Document   ];
                    logoutcontentFile=doc[0].body;
                    String[] filelines = new String[]{};
                    string nameFile=logincontentFile.toString();
                    return new Utility_RowIterator(nameFile,'\n');
 }
 global void execute(Database.BatchableContext BC, List<string> filelines ){
    Map<id,user> userList=new map<id,user>([select id,name,Email,Division,Username from user]);
       
        List<LogHistory__c> accstoupload;
        accstoupload = new List<LogHistory__c>();
        for (Integer i=1;i<filelines.size();i++)
        {
            String[] inputvalues = new String[]{};
            inputvalues = filelines[i].split(',');
            system.debug('inputvalues'+inputvalues);
            LogHistory__c a = new LogHistory__c();
            a.Name = inputvalues[0].remove('"');// event type
            a.USER_ID__c = inputvalues[4].remove('"'); // user id      
            a.CLIENT_IP__c = inputvalues[10].remove('"');//client ip
            //a.SOURCE_IP__c = inputvalues[11].remove('"');
            a.TIMESTAMP_DERIVED__c = inputvalues[18].remove('"');
            a.User_Division__c =userList.get( a.USER_ID__c).Division;
            a.User_Email__c=userList.get( a.USER_ID__c).email;
            a.User_Login_Mail__c=userList.get( a.USER_ID__c).Username;
            a.User_Name__c=userList.get( a.USER_ID__c).name;
            
            accstoupload.add(a);
            system.debug('accstoupload'+accstoupload);
        }
        
      insert accstoupload;
      
 }
 global void finish(Database.BatchableContext BC){              
    
 }  
}
  • December 02, 2015
  • Like
  • 0
if(Trigger.isBefore){
       if(Trigger.IsUpdate ){
            
           if(checkRecursive.runOnce()){


                        for(Account acc1:Trigger.New){
                                if(string.isNotBlank(acc1.Mobile_NO_Contact__c) ){
                                    if(acc1.Mobile_NO_Contact__c.isNumeric()){
                                            if(acc1.Mobile_NO_Contact__c!=Trigger.oldMap.get(acc1.id).Mobile_NO_Contact__c){
                                                acclists1.add(acc1);system.debug('acclist@@@@@@'+acclists1);
                                            }

                                    }
                                    else{
                                        acc1.addError('Please enter the valid mobile number');
                                    }

                                }   
                        }// end of for loop for modification  of mobile number.
                        if(!acclists1.isEmpty()){
                                accountTriggerHandler.beforeUpdateMethod(acclists1);
                        }

         
                        for(Account acc2:Trigger.New){
                                if(string.isNotBlank(acc2.Mobile_NO_Contact__c) ){
                                        if(acc2.Present_No_of_Years_in_Current_City__c!=null && (Trigger.oldMap.get(acc2.id).Present_No_of_Years_in_Current_City__c==null)){
                                                if(acc2.Mobile_NO_Contact__c.isNumeric()){
                                                    acclists2.add(acc2);system.debug('acclist@@@@@@'+acclists2);
                                                }
                                                else{
                                                    acc2.addError('Please enter the valid mobile number');
                                                }
                                        }

                                }
                        }// end of for loop.
                        if(!acclists2.isEmpty()){
                                accountTriggerHandler.beforeinsertMethod(acclists2);
                        }

                    }// end if loop for checking profile    
                    for(Account acc:Trigger.new){
                            system.debug('acc.Mobile_NO_Contact__c'+acc.Mobile_NO_Contact__c);
                            system.debug('acc.Customer_Id__c'+acc.Customer_Id__c);
                            system.debug('acc.zone__c'+acc.zone__c);
                            system.debug('Branch_Name__c'+acc.Branch_Name__r.Mobile_Flagging__c);
                            system.debug('Branch_Name__c'+acc.Branch_Name__c);
                            if(string.isNotBlank(acc.Mobile_NO_Contact__c) ){
                                if(acc.Mobile_NO_Contact__c.isNumeric()){
                                    acclist.add(acc);system.debug('acclist@@@@@@'+acclist);
                                    accountIds.add(acc.Id);
                                    branchIds.add(acc.Branch_Name__c);
                                }
                                else{
                                    acc.zone__c='Invalide';
                                }

                            }
                        }
                        if(!acclist.isEmpty()){
                                   accountTriggerHandler.beforeupdate(acclist);// Passing parameters to handler class of Trigger
                        }// end of one time updation
                            
                    }// end of recursion.
            }// end of   update.
        }//end of isBefore
Bold lines code not covering plz help me out
Thnaks in advanced.
  • October 22, 2015
  • Like
  • 0
<!--  public List<insClaimWra> getinsClaiDowload(){
     
           LIST<INSCLAIMWRA> INSROWS=NEW LIST<INSCLAIMWRA>();
           
           FOR(SOBJECT R : SETCON.GETRECORDS()){
               INSURANCE_CLAIM__C CLAIM=(INSURANCE_CLAIM__C)R;
               INSCLAIMWRA ROW = NEW INSCLAIMWRA(CLAIM,TRUE);
              IF(THIS.SELECTEDINSCLAIMIDS.CONTAINS(CLAIM.ID)){
                ROW.ISSELECTED=TRUE;
            }
            ELSE{
                ROW.ISSELECTED=FALSE;
            }
              INSROWS.ADD(ROW);
           }    
     
       return insRows;
    }
    // commonad button method
    Public PageReference downloadInsClaims(){
        selectedInsClaims= new List<Insurance_Claim__c>();
        UpdateList= new List<Insurance_Claim__c>();
        for(Insurance_Claim__c insclaims:[select id,name,Rejected_Reason__c,Client_Urn__c,ClaimSubmittedToInsDate__c ,RecordTypeId,Rejected_Date__c,Status__c from Insurance_Claim__c where id in:selectedInsClaimIds]){
           SELECTEDINSCLAIMS.ADD(INSCLAIMS);
           INSURANCE_CLAIM__C INS=NEW INSURANCE_CLAIM__C(ID=INSCLAIMS.ID);
           INS.CLAIMSUBMITTEDTOINSDATE__C=SYSTEM.TODAY();
           UPDATELIST.ADD(INS);
        }
        try{
        Database.update(UpdateList);
        //selectedInsClaims.addAll(UpdateList); //after  updated Recordslist
        }
        catch(DMLException e){
        }
        PageReference secondPage = new PageReference('/apex/insuranceClaimdownloadpage');
        secondPage.setRedirect(false);
        system.debug('selectedInsClaims################'+selectedInsClaims);
        return secondPage;
       

    }

upper case lines not get code coverage how to get code coverage for upper letters lines
 PageReference pageRef = Page.insuranceClaimdownload;
              Test.setCurrentPage(pageRef);
              insuranceClaimdownload ext = new insuranceClaimdownload();
              Insurance_Claim__c ins=new Insurance_Claim__c();
              Boolean flag;
              insuranceClaimdownload.insClaimWra cm=new insuranceClaimdownload.insClaimWra(ins,flag);
             // List<insuranceClaimdownload.insClaimWra> wrp = ext.getinsClaiDowload();
              //wrp.Isselected=true;
              ext.getHasNext();
               ext.getHasPrevious();
               ext.doPrevious();
               ext.setCon.next();
               ext.setCon.previous();
               ext.doSelectItem();
               ext.doDeselectItem();
               ext.getinsClaiDowload();
             
              for(insuranceClaimdownload.insClaimWra wrp:ext.getinsClaiDowload()){
                wrp.Isselected=true;
              }
             
             ext.doNext();
              
             ext.downloadInsClaims();
             inscl.ClaimSubmittedToInsDate__c=system.today();         
             inscl.status__c='Claim Submitted to Ins';
             inscl.RecordTypeId=ClaimSubmittedToIns;
              inscl.Upload_Date__c=system.today();
             update inscl;
              ext.getdownLoadRecordlist();
  • September 29, 2015
  • Like
  • 0
Hi All,
 i want send email to Regional manager for end of the day how many Opportunities are created throw batch apex.

  In Email body :  Opportunity name       status                       UniqNumber.
                             name1                   completed                   212323333
                             name1                   completed                   212323333

like this format i need to send mail to regional head.

Thanks in advanced
  • September 04, 2015
  • Like
  • 0
HI All:  i have one scenario
Oppoerunity is closed/won then we need to create one child Record for Opportunity.we are captruring Closed/won date.
when closed/won date (28/8/2015) then user within 10days(8/9/2015) user unable to create child record send email to salesmanagaer.
In mail we need send minimum oppoerutnity details to salesmanager
How can i do it ?help me out
  • August 28, 2015
  • Like
  • 0
Hi All,
   public void  SelectedAccounts() {
       for(OpportunityWrapper oOpp: getOpportunities()) {
              if(oOpp.selected == true) {
                  selectedOpportunities.add(oOpp.SO);
                  AccIds.add(oOpp.SO.AccountId);
              }
          }


===============
        for(Account a:[select id,name,Middle_Nam__c,CIS_No_new__c from Account where id =:AccIds]){
            a.Middle_Nam__c= cisChar+ String.valueOf(cisCounter);
            cisCounter=cisCounter-1;
            setAcc.add(a);
         
        }
     
 
THanks in advanced.
 
  • July 20, 2015
  • Like
  • 0
Hi All,
please help me out...bellow scenario

  In my visualforce page i display 10 Records with check box,by using wrapper class and i selecting 5 Records and Click on Printer button,it will print 5 Records details in my printer.
 
  • May 12, 2015
  • Like
  • 0
Hi All,
plz help me out...

public pagerefernce Accnext(){
 if(Secondary.Guardian_Name__c!=null &&((Secondary.Guardian_Age__c< 18)||(Secondary.Guardian_Age__c==null))){            AddError('Error: Guardian Age should be greater than equals to 18 ');
           return null;
    }
   else{
              try{ Account.Sex__c='F';Upsert(Account);            if( (Secondary.Relationdhip_with_Secondary_Customer__c=='Brother') || (Secondary.Relationdhip_with_Secondary_Customer__c=='Father')                 || (Secondary.Relationdhip_with_Secondary_Customer__c=='Fathein-law') || (Secondary.Relationdhip_with_Secondary_Customer__c=='Husband')                || (Secondary.Relationdhip_with_Secondary_Customer__c=='Son')){
                   Secondary.Gender__c='M';
           }
               Secondary.Account__c= Account.id;
                upsert(Secondary);
               nextTabValue = 'ContactDetails';               
              // adding primary customer into family member
                wrappers[0].name=Account.name;wrappers[0].Gender__c=Account.Sex__c;wrappers[0].Education__c=Account.Education1__c;                 wrappers[0].Marital_Status__c=Account.Marital_Status__c;                 if(Account.Natureofemployment__c=='Self- Employed' || Account.Natureofemployment__c=='Salaried'){                     wrappers[0].Occupation_Types__c='Employed';                 }                else if(Account.Natureofemployment__c=='Not-Employed' &&((Account.Type_of_Employment__c=='House wife') ||(Account.Type_of_Employment__c=='Others'))){                   wrappers[0].Occupation_Types__c='Not Employed';                }                else{                    wrappers[0].Occupation_Types__c='Student';                }                //=========================================================================               // Adding Secondary customer details into family member             if(Secondary.Relationdhip_with_Secondary_Customer__c!='Group Member' && Secondary.Type_of_Relation__c !='Group Member'){                  wrappers[1].name=Secondary.Name;                  wrappers[1].Gender__c=Secondary.Gender__c;                  wrappers[1].Education__c=Secondary.Educations__c;                  wrappers[1].Marital_Status__c=Secondary.Marital_Statuss__c;                  if(Secondary.Nature_of_Employment__c=='Self-Employed' || Secondary.Nature_of_Employment__c=='salaried'){                         wrappers[1].Occupation_Types__c='Employed';                  }                  else if(Secondary.Nature_of_Employment__c=='Not-Employed' &&((Secondary.Type_of_Employment__c=='House wife') ||(Secondary.Type_of_Employment__c=='Others'))){                      wrappers[1].Occupation_Types__c='Not Employed';                  }                  else{                       wrappers[1].Occupation_Types__c='Student';                  }            }
 


Thanks in Advance....
  • March 30, 2015
  • Like
  • 0
HI All,
please help me out for the bellow method how to write test class.

   public void delWrapper(){
   
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));         system.debug('rowNum '+rowNum );         wrappers.remove(rowNum);  // here wrappers is pageblockTable method     
        system.debug('wrappers&&&&&&&&&&'+wrappers);        
        lstacc1 =[Select id,Name from Family__c where id=:dcid];         
         system.debug('lstacc1'+lstacc1 );        
        delete lstacc1;
}
IN test class it showing Error ::Arguments can not be null;
test class
obj.rowNum = Integer.valueOf(apexpages.currentpage().getparameters().put('index','1'));
obj.delWrapper();// calling method from test clss

2.constructor.

  Public deosearchpage(){
   AccountID=apexpages.currentpage().getparameters().get('accId');
  if(AccountID!=null){
try{
     Acc=[select id ,name from account where id=:AccountID];
   }
catche(){

  }
}
}
HOw to write test class for above once also
  • March 29, 2015
  • Like
  • 0
 it is urgent Requirement plz help me out.
 // Constructor 
    public DEOSearchPageController(){
        Account=new Account();
        Opportunity= new Opportunities__c ();
        Secondary= new Secondary_Customer_Details__c();
        wrappers=new List<Family__c>();
        SECCCID=ApexPages.currentPage().getParameters().get('secId');
        AcccountID=ApexPages.currentPage().getParameters().get('accId');//DEOVfPagerforClient id can capture
        DEOVPC=ApexPages.currentPage().getParameters().get('DEOVPC');
        if(String.isNotBlank(AcccountID) && String.isNotBlank(DEOVPC)){
          try{
               acc=[  select Name,NCO_Occupation_Code__c,Main_Product_or_Service_sold__c,RecordtypeId from Account where Id=:AcccountID];
                 Account=acc;
                 SameFlag=Account.Same_As_Communication_Address__c;
                 system.debug('account.Same_As_Communication_Address__c'+account.Same_As_Communication_Address__c);
                 system.debug('Account************'+Account);
          }
          catch(QueryException e){
          }
           
        }
         DVPOP=ApexPages.currentPage().getParameters().get('DVPOP');
         system.debug('SECCCID*****'+SECCCID+'DEOVPC********'+DVPOP);
         if(String.isNotBlank(SECCCID)&&String.isNotBlank(DVPOP)){
             try{
                  // old soql sec =[select Id, Name ,Account__c,/* by ashok Guardian_Age__c,*/NCO_Occupation_Code__c,Industry__c,Main_Product_or_Service_sold__c,Brief_Description_of_Occupation_words__c,Salutation__c,Alias__c,Last_Name__c ,FH_FirstName__c ,FH_MiddleName__c ,FH_LastNames__c,Date_of_Birtht__c,Gender__c,Mother_Tongue__c ,Educations__c,Marital_Statuss__c,Identity_Proofs__c,Identity_ProofNo__c,Type_of_Relation__c,Relationdhip_with_Secondary_Customer__c,Proof_b_w_Borrower_and_Co_Borrower__c,Nature_of_Employment__c,Type_of_Employment__c,Frequency_of_wages__c ,If_Others_Please_Specify__c,Months3__c,Nominee_Name__c ,Nominee_Age_SC__c,Nominee_Relationship_with_Primary__c,Guardian_Name__c,Guardian_Relationship__c,Nominee_Bank_Name__c,Nominee_Bank_Account_Number__c,BALIC_Member_No__c,Policy_Period_Start_Date__c,Policy_Period_End_Date__c,Premium_Paid__c,Sum_Assured__c,BALIC_Member_No_SC__c ,Policy_Period_Start_Date_SC__c,Policy_Period_End_Date_SC__c ,Premium_Paid_SC__c ,Sum_Assured_SC__c,Length_of_Business_Service_Years__c from Secondary_Customer_Details__c  where Id =:SECCCID limit 1];
                    sec=[   select Id, Name ,Account__c,NCO_Occupation_Code__c,Brief_Description_of_Occupation_words__c,
                            Industry__c,Main_Product_or_Service_sold__c,Salutation__c,Last_Name__c ,
                            Length_of_Business_Service_Years__c,Aadhar_Card__c,Aadhar_Card_No__c,Guardian_Age__c,
                            Spouse_First_Name_SC__c,Spouse_Last_Name_SC__c  from Secondary_Customer_Details__c  where Id =:SECCCID limit 1];
             }
             catch(QueryException e){
                    system.debug('********'+e);
                     //LogsExceptionClass.insertLog(e.getMessage(),e.getLineNumber(),e.getTypeName(),String.valueOf(e.getcause()),e.getStackTraceString());
            }
            String accountId=sec.Account__C;
            system.debug('accountId*********'+accountId);
            if(String.isNotBlank(accountId)){
                try{
                    acc=[  select Name,NCO_Occupation_Code__c,Main_Product_or_Service_sold__c,RecordtypeId from Account where Id=:AcccountID];
                     account=acc;
                     SameFlag=account.Same_As_Communication_Address__c;
                     system.debug('account.Same_As_Communication_Address__c'+account.Same_As_Communication_Address__c);
                     string accountIds = acc.Id;
                
                
                     String sql='select name,Gender__c,Chief_wage_earner_of_the_family__c,Education__c,Marital_Status__c,Occupation_Types__c,CIS__c FROM Family__c where CIS__c=:accountIds';
                     wrappers= Database.Query(sql);
               
                }
                catch(QueryException e){
                    system.debug('********'+e);
                     //LogsExceptionClass.insertLog(e.getMessage(),e.getLineNumber(),e.getTypeName(),String.valueOf(e.getcause()),e.getStackTraceString());
                }   
            }
             
         }
         DSANew=ApexPages.currentPage().getParameters().get('DSANew');
         system.debug('SECCCID*****'+SECCCID+'DSANew********'+DSANew);
         if(string.isNotBlank(DSANew) && String.isNotBlank(SECCCID)){
                try{ 
                 //old soql sec =[select Id, Name ,NCO_Occupation_Code__c,Industry__c,Main_Product_or_Service_sold__c,Brief_Description_of_Occupation_words__c,Account__c,Salutation__c,Spouse_First_Name_SC__c,Spouse_Last_Name_SC__c,Alias__c,Last_Name__c ,FH_FirstName__c ,FH_MiddleName__c ,FatherOrHusband__c,FH_LastNames__c,Date_of_Birtht__c,Gender__c,Mother_Tongue__c ,Educations__c,Marital_Statuss__c,Identity_Proofs__c,Identity_ProofNo__c,Type_of_Relation__c,Relationdhip_with_Secondary_Customer__c,Proof_b_w_Borrower_and_Co_Borrower__c,Nature_of_Employment__c,Type_of_Employment__c,Frequency_of_wages__c ,If_Others_Please_Specify__c,Months3__c,Nominee_Name__c ,Nominee_Age_SC__c,Nominee_Relationship_with_Primary__c,Guardian_Name__c,Guardian_Relationship__c,Nominee_Bank_Name__c,Nominee_Bank_Account_Number__c,BALIC_Member_No__c,Policy_Period_Start_Date__c,Policy_Period_End_Date__c,Premium_Paid__c,Sum_Assured__c,BALIC_Member_No_SC__c ,Policy_Period_Start_Date_SC__c,Policy_Period_End_Date_SC__c ,/* ashok Guardian_Age__c,*/ Premium_Paid_SC__c ,Sum_Assured_SC__c,Length_of_Business_Service_Years__c  from Secondary_Customer_Details__c  where Id =:SECCCID limit 1];
                    sec =[  select Id, Name ,Account__c,NCO_Occupation_Code__c,Brief_Description_of_Occupation_words__c,
                            Industry__c,Main_Product_or_Service_sold__c,Salutation__c,Last_Name__c ,
                            FH_FirstName__c ,FH_MiddleName__c ,FH_LastNames__c,Date_of_Birtht__c,
                            Length_of_Business_Service_Years__c,Aadhar_Card__c,Aadhar_Card_No__c,Guardian_Age__c,
                            Spouse_First_Name_SC__c,Spouse_Last_Name_SC__c from Secondary_Customer_Details__c  where Id =:SECCCID limit 1];
                        Secondary=sec;
                        String accountId=Secondary.Account__C;
                            if(String.isNotBlank(accountId)){
                                    //old soql acc=[select Name,NCO_Occupation_Code__c,Main_Product_or_Service_sold__c,Industry,Brief_Description_of_Occupation_words__c,Total_Outflow__c,DO_You_Have_Mobile_No__c ,DO_You_Have_Land_Line_No__c ,Does_the_applicant_live_in_address_spcfd__c,Net_Cash_Flow__c,Total_Inlfow__c ,Branch_Name__r.Branch_Type__c,Occupation_Description__c ,Does_Coapplicant_have_a_seperate_family__c,Specify_the_Correct_Address__c  ,Does_Coaplicant_live_in_same_address__c ,No_of_Earning_Members__c ,City_Borrower__c ,DesignationOther1__c ,Length_of_business_serviceYears__c ,Batch_Leader__c,Employment_Type__c ,isPersonAccount,Father_Husband_s_Middle_Name__c , Account_Status__c ,Batch_Leader_Credit_Bureau_Rejected__c,Area_lookup__c,CIS_No_new__c,Branch_Name__c,Application_serial_number__c,Net_Cash_Flow_120_EMI__c,InstaKit_Account_No__c,Customer_Id__c,Aadhar_Card_No__c,Aadhar_Card__c,Product_type__c,Opted_for_NPS_Lite__c, Customer_Consent_on_NPS_Lite_Debit__c,test1__c, Amount_debited_for_NPS_LITE_inclusion__c,Spouse_Last_Name__c,Spouse_First_Name__c, Enrollment_Date__c,Default_Status__c,URN_No_Asset__c,Person_Account_ID__c ,Enrollment_Type__c ,CRE_Sales_NameLP__c,All_application_in_batch_sanctioned__c,Last_URNNumber__c,No_of_Groups_Attached__c,TCBIL_Last_URN__c,Card_Dispatch_Status__c,Card_Print_Status__c,Salutation__c,Alias__c,LastName__c,DeDuplication_Status__c,DOB_Borrower__c, Age_of_Borrower1__c,Father_OR_Husband__c,Marital_Status__c,Father_Husband_s_First_Name__c ,Education1__c, F_H_s_Last_Name__c ,IdentityProofNo__c ,Sex__c,MotherTongue__c,IdentityProof__c ,IdentityProof_coborr__c,IdentityProofNo1__c,Religion__c ,Caste__c ,Natureofemployment__c,Type_of_Employment__c ,Occupation_Code__c,DesignationOther__c ,Designation__c ,Frequency_of_wages__c ,Months1__c  ,Pin_COntacts__c ,Landmark_contacts__c, No_of_Years_in_Current_Residence__c , Outflow_Excluding_Financial_expenses__c, Financial__c , Home_Telephone_No__c,OWN_PP_Home__c ,Office_Telephone_No__c , Ext_Res__c ,Mobile_NO_Contact__c,OWN_PP__c ,Door_No_Main_Borrower__c,Street_Name_main__c , Present_No_of_Years_in_Current_City__c , Is_the_residence_in_a__c, Other_Residence__c , Door_No_contact__c, Street_Name_Contact__c, City_Contact__c , Pin_contact__c  , Landmark__c  from Account where Id=:accountId limit 1];
                                    try{ acc=[  select Name,NCO_Occupation_Code__c,Main_Product_or_Service_sold__c,RecordtypeId from Account where Id=:AcccountID];
                                            account=acc;
                                            SameFlag=account.Same_As_Communication_Address__c;
                                            system.debug('account.Same_As_Communication_Address__c'+account.Same_As_Communication_Address__c);
                                            system.debug('accountId****'+accountId);
                                            //old soql String sql = 'SELECT Age__c,Amount_Earned_per_month_Dependent__c,CreatedById,CreatedDate,CurrencyIsoCode,Family_setup__c,Frequency_of_income_earned1__c,Id,IsDeleted,LastModifiedById,LastModifiedDate,MigratedRecordsFlag__c,Name,Occupation_Class_if_student__c,Occupation_Code_family__c,education__c,Chief_wage_earner_of_the_family__c,Occupation_Description_Family__c,OwnerId,Personal_Assets__c,Personal_Liabilities__c,Relationship_with_the_family_member__c,Status_of_Health__c,CIS__c FROM Family__c where CIS__c=:accountId';
                                            String sql='select name,Gender__c,Education__c,Chief_wage_earner_of_the_family__c,Marital_Status__c,Occupation_Types__c,CIS__c FROM Family__c where CIS__c=:accountId';
                                            wrappers= Database.Query(sql);
                                            system.debug('Families ***********'+Families );
                                            //old soql op=[Select Id,Loan_Jump_checkbox__c ,MIMO_Account_ID__c,CRM_s_Signature_Date_Time__c,CRE_Collection_s_NameLp__c,CRM_s_Name_Lookup__c,MIMO_Closed_customer__c,Account__c,CRE_Sales_Signature_Date_Time__c,Installment_Amount__c,CRE_Sales_NameLP__c,Does_Coapplicant_have_a_seperate_family__c,Does_Coaplicant_live_in_same_address__c,Specify_the_Correct_Address__c,Does_the_applicant_live_in_address_spcfd__c,Loan_Purpose_Description__c,Declaration_Completed__c,Loan_Purpose__c,Income_Assesment_remarks__c,No_of_Family_Members__c,Securityb__c,Loan3_Frequency__c,Repayment_Amount_p_ms__c,Loan_outstandingb__c,Original_Loan_Amountt__c,Loan3_Purpose__c,Sourcet__c,Securitys__c,Loan2_Frequency__c,Repayment_Amount_p_mb__c,Loan_outstandings__c,Original_Loan_Amounts__c,Purposes__c,Sources__c,Security__c,Loan1_frequency__c,Repayment_Amount_p_m__c,Loan_Outstanding__c,Original_Loan_Amount__c,Purpose__c,Source1__c,Vehicle_Used__c,PressureCooker_s_new__c,Durables_Owned__c,Electric_Fans_new__c,Type_Of_Residence__c,Type_of_property_owned_in_city__c,Residential_Status_Currently__c,Gold_new__c,Post_Office_SB_Ac__c,CHITS_new__c,Savings_Others_new__c,Savings_A_C_new__c,RD_FD_recurring_new__c,SHG_Savings_new__c,Opportunity_Status__c,OwnerId,URN__c,Status__c,Stage__c,CloseDate__c,Loan_Amount__c,Loan_Cycle__c,Probability__c,Product_Name__c,Date_of_Credit_check__c,Credit_Bureau_Status__c,Low_Credit_Score_Deviation__c,Type_of_Closure_Writeoff_text__c,Opp_Selected__c,Opted_for_Prepaid__c,Closure_Letter_Attached__c,Amcl__c,Loan_account_No__c,Mcl__c,CBS_Loan_Status__c,Customer_Type__c,Credit_check_with_history__c,Previous_Record_Type__c,Record_Type_Changed__c,Center_Number__c,Margin_Money__c,Next_DisbursementDate__c,Credit_Bureau_Rejected_Reason__c,Actual_DisbursementDate__c,Group_Leader__c,Product_Application_No__c,Group_No__c,Is_the_Net_CashFlow_120_of_EMI__c,Previous_Opportunity_CBS_Loan_Status__c,Secondary_Customer_Details__c,Name,Does_your_family_own_any_agricul_land__c,If_yes_No_of_Acres__c from Opportunities__c where Account__c=:accountId and (Status__c= 'Assigned' OR Status__c= 'Active') Limit 1];
                                            op=[Select Id,Remarks_Official__c,Amount_debited_for_NPS_LITE_inclusion__c,Customer_Consent_on_NPS_Lite_Debit__c,CRE_Sales_NameLP__r.Employee_Code__c,Total_no_of_non_earning_members__c,Loan_Jump_checkbox__c ,MIMO_Account_ID__c,CRM_s_Signature_Date_Time__c,CRE_Collection_s_NameLp__c,CRM_s_Name_Lookup__c,MIMO_Closed_customer__c,Account__c,CRE_Sales_Signature_Date_Time__c,Installment_Amount__c,CRE_Sales_NameLP__c,Does_Coapplicant_have_a_seperate_family__c,Does_Coaplicant_live_in_same_address__c,Specify_the_Correct_Address__c,Does_the_applicant_live_in_address_spcfd__c,Loan_Purpose_Description__c,Declaration_Completed__c,Loan_Purpose__c,Income_Assesment_remarks__c,No_of_Family_Members__c,Securityb__c,Loan3_Frequency__c,Repayment_Amount_p_ms__c,Loan_outstandingb__c,Original_Loan_Amountt__c,Loan3_Purpose__c,Sourcet__c,Securitys__c,Loan2_Frequency__c,Repayment_Amount_p_mb__c,Loan_outstandings__c,Original_Loan_Amounts__c,Purposes__c,Sources__c,Security__c,Loan1_frequency__c,Repayment_Amount_p_m__c,Loan_Outstanding__c,Original_Loan_Amount__c,Purpose__c,Source1__c,Vehicle_Used__c,PressureCooker_s_new__c,Durables_Owned__c,Electric_Fans_new__c,Type_Of_Residence__c,Type_of_property_owned_in_city__c,Residential_Status_Currently__c,Gold_new__c,Post_Office_SB_Ac__c,CHITS_new__c,Savings_Others_new__c,Savings_A_C_new__c,RD_FD_recurring_new__c,SHG_Savings_new__c,Opportunity_Status__c,OwnerId,URN__c,Status__c,Stage__c,CloseDate__c,Loan_Amount__c,Loan_Cycle__c,Probability__c,Product_Name__c,Date_of_Credit_check__c,Credit_Bureau_Status__c,Low_Credit_Score_Deviation__c,Type_of_Closure_Writeoff_text__c,Opp_Selected__c,Opted_for_Prepaid__c,Closure_Letter_Attached__c,Amcl__c,Loan_account_No__c,Mcl__c,CBS_Loan_Status__c,Customer_Type__c,Credit_check_with_history__c,Previous_Record_Type__c,Record_Type_Changed__c,Center_Number__c,Margin_Money__c,Next_DisbursementDate__c,Credit_Bureau_Rejected_Reason__c,Actual_DisbursementDate__c,Group_Leader__c,Product_Application_No__c,Group_No__c,Is_the_Net_CashFlow_120_of_EMI__c,Previous_Opportunity_CBS_Loan_Status__c,Secondary_Customer_Details__c,Name,Does_your_family_own_any_agricul_land__c,If_yes_No_of_Acres__c from Opportunities__c where Account__c=:accountId and (Status__c= 'Assigned' OR Status__c= 'Active') Limit 1];
                                            system.debug('op################'+op);
                                            Opportunity=op;
                                            system.debug('Opportunity@@@@@@@@@@@@'+Opportunity);
                                    }
                                    catch(QueryException e){
                                    }
                            }
                }
                catch(QueryException e){
                    system.debug('********'+e);
                }
            }   
         smalGroupProduct = new Product2();
        smalGroupProduct=[SELECT id,PRODUCT_CODE__c,Name FROM Product2 WHERE PRODUCT_CODE__c = 814 Limit 1];
        SMALLGROUPSPECIAL = new Product2();
        SMALLGROUPSPECIAL=[SELECT id,PRODUCT_CODE__c,Name FROM Product2 WHERE PRODUCT_CODE__c = 815 Limit 1];
        RecordType AccountRt= [SELECT DeveloperName,Id,Name FROM RecordType where DeveloperName='Client_Draft_Mode'];
        RecordType SecondaryRt= [SELECT DeveloperName,Id,Name FROM RecordType where DeveloperName='For_DEO' and sobjectType='Secondary_Customer_Details__c'];
        system.debug('*****SecondaryRt*******'+SecondaryRt.Name+'AccountRt'+AccountRt.name);
        account.RecordtypeId=AccountRt.Id;
        Secondary.RecordtypeId=SecondaryRt.Id;
        system.debug('account.RecordtypeId'+account.RecordtypeId);
        Integer size1=wrappers.size();
        system.debug('size1'+size1);
        for(integer i=0;size1<8;i++){
            wrappers.add(new family__c());
           size1++; 
       }
 }
 
  • March 22, 2015
  • Like
  • 0
Hi All,
please give me the solutaions on bellow one.

  I created 1 field and Datatype is Text[50],by using these field in my visualforce page,by defualt it showing some junk value.i dont want that junk value in my visualfroce page .why these text field showing by defualt some junk value.


please  help me out...
 
  • March 20, 2015
  • Like
  • 0
Hi All plz tell me how to write test class for bellow method


public PageReference AccNext() {                  if(Account.CIS_No_new__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter CIS number');            ApexPages.addMessage(msg);             if(!test.isrunningTest())            return null;         }         if(Account.Salutation__c == Null){           ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Salutation for primary customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;          }         if(Account.LastName__c== Null){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Primary customer Lastname');            ApexPages.addMessage(msg);             if(!test.isrunningTest())            return null;         }                       //====================== new logic added for salutation and gender matching for Primary/Secondary Customer=====================         if(Account.Sex__c != Null && Account.salutation__c != Null && Account.salutation__c == 'Mrs.' && Account.Sex__c == 'M'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Female under Primary Customer Details');            ApexPages.addMessage(msg);                if(!test.isrunningTest())            return null;                  }         if(Account.Sex__c != Null && Account.salutation__c != Null && Account.salutation__c == 'Mr.' && Account.Sex__c == 'F'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Male under Primary Customer Details');            ApexPages.addMessage(msg);                if(!test.isrunningTest())            return null;                  }        if(Account.Sex__c != Null && Account.salutation__c != Null && Account.salutation__c == 'Ms' && Account.Sex__c == 'M'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Female under Primary Customer Details');            ApexPages.addMessage(msg);                if(!test.isrunningTest())            return null;                  }                                    //========================================= end of new logic ===============================================================================================         if(Account.Marital_Status__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer marital status');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Account.Education1__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer Education');            ApexPages.addMessage(msg);             if(!test.isrunningTest())             return null;                  }                  if(Account.IdentityProof__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer ID type1');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Account.IdentityProofNo__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer Identity No');            ApexPages.addMessage(msg);              if(!test.isrunningTest())           return null;                  }         //updated for new id proof details         if(Account.IdentityProof_coborr__c==Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer ID type2');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Account.IdentityProofNo1__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer Identity No2');            ApexPages.addMessage(msg);              if(!test.isrunningTest())           return null;                  }// updation end -         if(Account.Aadhar_Card__c=='Yes' && (Account.Aadhar_Card_No__c==null || Account.Aadhar_Card_No__c=='')){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Aadhar card Number');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Secondary.Name== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer First name');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Secondary.Last_Name__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer Last name');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Secondary.Salutation__c == Null)         {           ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Salutation for secondary customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;          }          if(Account.Name == Secondary.Name && Account.LastName__c ==   Secondary.Last_Name__c){             ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Primary and Secondary customer name should not be same');            ApexPages.addMessage(msg);              if(!test.isrunningTest())           return null;         }         if(Secondary.Date_of_Birtht__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary Customer Date of Birth');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(((Secondary.FH_FirstName__c == Null || Secondary.FH_LastNames__c == Null) && (Secondary.Spouse_First_Name_SC__c== Null || Secondary.Spouse_Last_Name_SC__c == Null)) && Account.Opted_for_NPS_Lite__c == 'No')  {            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Fathers/Spouse first name and last name of Secondary Customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;                  }                  if( (Secondary.FH_FirstName__c== Null || Secondary.FH_LastNames__c == Null)&& Account.Opted_for_NPS_Lite__c == 'Yes'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Fathers first and last name of Secondary customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;                  }         /*  Logi for Gender and Salutation  */         if(Secondary.Gender__c != Null && Secondary.Salutation__c != Null && Secondary.Salutation__c == 'Mr.' && Secondary.Gender__c == 'F'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Male under Secondary Customer Details');            ApexPages.addMessage(msg);             if(!test.isrunningTest())            return null;                     }           if(Secondary.Gender__c != Null && Secondary.Salutation__c != Null && Secondary.Salutation__c == 'Mrs.' && Secondary.Gender__c == 'M'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Female under Secondary Customer Details');            ApexPages.addMessage(Msg);             if(!test.isrunningTest())            return null;                     }                            if(Secondary.Marital_Statuss__c== Null ){                 ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Secondary customer Marital Status');                 ApexPages.addMessage(msg);                 if(!test.isrunningTest())                  return null;             }         */          if(Secondary.Educations__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer Education');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Secondary.Identity_Proofs__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer ID Type');            ApexPages.addMessage(msg);             if(!test.isrunningTest())             return null;                  }         if(Secondary.Identity_ProofNo__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Secondary customer Identity Proof No');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Secondary.Gender__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer SEX');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Secondary.Nature_of_Employment__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Secondary customer Nature of Employement');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Account.Caste__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Caste');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Account.Religion__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Religion');            ApexPages.addMessage(msg);             if(!test.isrunningTest())             return null;                  }                     else         {                       try{                                  Upsert(Account);                 Account StdaccListfmly = new Account();                             RecordType SecondaryRt= [SELECT DeveloperName,Id,Name FROM RecordType where DeveloperName='For_DEO' and sobjectType='Secondary_Customer_Details__c'];                                  Secondary.RecordtypeId=SecondaryRt.Id;                 StdaccListfmly=[Select id, Name,Age_of_Borrower1__c,Natureofemployment__c from Account where Id =:account.Id limit 1];                 Secondary.Account__c= StdaccListfmly.id;                 upsert(Secondary);//Database.upsert(Secondary); commented by bhanu to catch dml exception - 3 dec                 Secondary_Customer_Details__c SecListfmly = new Secondary_Customer_Details__c();                 SecListfmly=[Select id,Nature_of_Employment__c,Type_of_Relation__c,Length_of_Business_Service_Years__c ,Relationdhip_with_Secondary_Customer__c,Name,Age_of_Co_Borrower__c from Secondary_Customer_Details__c where Id =:Secondary.Id limit 1];                 system.debug('**********Relationdhip_with_Secondary_Customer__c***********'+SecListfmly.Relationdhip_with_Secondary_Customer__c);                 system.debug('**********Type_of_Relation__c***********'+SecListfmly.Type_of_Relation__c);                 String nextTabValue = 'ContactDetails';                   if(nextTabValue != null){                    currentTab = nextTabValue;                         Opportunity.Account__c= account.id;                      Opportunity.Secondary_Customer_Details__c=secondary.Id;                                                          }            }            catch(DmlException e){                 ApexPages.addMessages(e);                 LogsExceptionClass.insertLog(e.getMessage(),e.getLineNumber(),e.getTypeName(),String.valueOf(e.getcause()),e.getStackTraceString());            }        }        return null;     }

 
  • March 06, 2015
  • Like
  • 0
public PageReference exportData()
    {
        String ssql;
        pageReference pg = null;
        String header = setFieldHeader(true);      
            
        if(!String.isEmpty(header))          
        {               
            fieldHeader = header;
            if(exportEncodingType == 'Unicode') {
                fieldHeader = EncodingUtil.convertFromHex('EFBBBF').toString() + fieldHeader;
            }
            system.debug('???selectedObjectName'+selectedObjectName);
            if (selectedObjectName == 'GSD_Resource_Skill__c') {
                fieldList.add('Resource__r.CKSW__ID__c');
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c WHERE Resource__r.CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c WHERE Resource__r.CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c LIMIT 50000';
                }
            } else if (selectedObjectName == 'CKSW__Engineer_Equipment__c') {                
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c WHERE CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c WHERE CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c LIMIT 50000';
                }
            }  else if (selectedObjectName == 'GSD_Resource_District__c') {
                fieldList.add('Resource__r.CKSW__ID__c');                
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c WHERE Resource__r.CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c WHERE Resource__r.CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c LIMIT 50000';
                }                               
            } else if (selectedObjectName == 'GSD_Resource_District_Mapping__c') {
               // fieldList.add('GSD_Resource__r.First_name__c');
               // fieldList.add('GSD_Resource__r.Last_name__c');
                
                Integer index1 = 0;
                for(String strList : fieldList) {
                    if(strList == 'GSD_Resource__r.Name') fieldList[index1] = 'GSD_Resource__r.User__r.Name';                 
                    index1++;
                }              
                fieldList.add('GSD_Resource__r.Employee_ID__c');               
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c WHERE GSD_Resource__r.Country_ISO__r.name In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c WHERE GSD_Resource__r.Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c LIMIT 50000';
                }
            } else if (selectedObjectName == 'GSD_Resource_Skills_mapping__c') {         
                Integer index = 0;
                for(String strList : fieldList) {
                    if(strList == 'Resource_ID__r.Name') fieldList[index] = 'Resource_ID__r.User__r.Name';                 
                    index++;
                }                               
                fieldList.add('Resource_ID__r.employee_id__c');                 
                if (filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c WHERE Resource_ID__r.Country_ISO__r.name In (\'' + String.join(CurrentList, '\',\'') + '\')  AND Web_App_Employee_Id__c = \''+'\' LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c WHERE Resource_ID__r.Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') AND Web_App_Employee_Id__c = \''+'\' LIMIT 50000';
                }
                else {                                
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c LIMIT 50000';              
                }                           
            } else if (selectedObjectName == 'GSD_Resource__c') {
                List<String> templist = new List<String>();             
                templist.add(fieldlist[0]);             
                templist.add('User__r.Legacy_Employee_Ref__c');
                fieldList[1] = 'User__r.Name';
                fieldlist.remove(0);
                templist.addAll(fieldlist);
                fieldlist = templist;
                /*Integer index = 0;
                for(String strList : fieldList) {
                    if(strList == 'Employee_ID__c') fieldList[index] = 'User__r.Name';                 
                    index++;
                }           
                fieldList.add('User__r.Legacy_Employee_Ref__c');*/
                if (filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c WHERE Country_ISO__r.Name In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c WHERE Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c LIMIT 50000';                           
                }
            }
            system.debug('??? fieldList......'+fieldList);
            system.debug('??? query structure...'+ssql);
            
            objLst = new List < sObject > ();
            ListobjLst = new List <List<sObject>> ();  
            for (sobject s: Database.Query(ssql)) {
                   objLst.add(s);
                if (objLst.size() == 1000) { //limit of vf repeat components
                    ListobjLst.add(objLst);
                    objLst = new List < sobject > ();
                }
            }
            ListobjLst.add(objLst);
            pg = new pageReference('/apex/GSDBulkTemplate');
            pg.setRedirect(false);
        }        
        return pg;
    }
  • March 01, 2015
  • Like
  • 1
HI FNds can you help me out.........

 public string[] getclientLastName(){
        String temp;
        if((acc[0].Alias_Client_First_Name__c != Null)&&(acc[0].Alias_Client_Last_Name__c != Null)){
            temp = acc[0].Alias_Client_Last_Name__c;
        }
        else{
            temp = acc[0].LastName__c;
        }
        
        system.debug('----------'+temp);
        clientLastName = new string[30];
        if(temp == Null){
            for(integer i=0 ; i< 30; i++){
                clientLastName [i] = ' ';
            }
            return clientLastName;
        }
        integer totallenngth = 30;
        integer realLength = temp.length();
        if( realLength > 30){
            realLength = 30;
        }
        integer remaingLength = 30 - realLength;
        
        temp = temp.toUpperCase();
        for(integer i=0;i<realLength ;i++){
            clientLastName[i] = temp.substring(i,i+1);
            system.debug('----'+i);
        }
        for(integer i=realLength;i< totallenngth ;i++){
            clientLastName[i] = ' ';

        }
        return clientLastName;
    }
   

Thanks for in advanced
  • February 10, 2015
  • Like
  • 0
Hi fnds.
Q:: in my page account  Records displaying with check box,by defualt all records are checked and when i click on Print Button my visualforce page it will print the all Records with their Related information.
Example: i have 10 Records in my page and i checked only 7 Records and i click on Print Button my page,it will print Each Record as one page with theire related date.[i selected 7 Records,it print 7 pages].
plZ help me out

Thanks in Advanced
  • January 29, 2015
  • Like
  • 0
Hi Fnds.. plz help me out this

  Q:: I have picklist(product_type__c) having Lov's of(type1,type2,type3,type4),i have another field like description__c(text).
   when i select the type1,descripton is not mandatory,but when i select otherthan type1,description is mandatory filed when click on save button it show msg like description is mandatroy


 
  • January 20, 2015
  • Like
  • 0
Hi fnds...

 Iam 401(SU-14) Certified Developer and when i write for maintance exam and how can i check if any maintance exams available or not..

Maintaince exams are free or chargeable
plz help me out

Regards
NNR
  • January 06, 2015
  • Like
  • 0
Hi Fnds..

 In my organation i have one profile is CanadaUsers, i have send a Email to user's Reset your password with link.

Example:: Adminin can send individuals user's resetpassword link when click on Resetpassword button on profile and check the checkbox for user

like above i can send emails to all user's in particular profile


Thanks in Advance
Nnr
 
  • December 27, 2014
  • Like
  • 0
Hi All,
  public void savemethod(){
  acc.name='cname';
  acc.annualrevenue='2123';
  acc.RecordtypeId='001K0000012C7C2';// here id is account1 record type id
  insert acc;
}
above method succussful inserting Record but when i click details of Record it is inserting another Recordtype is name 'account2'
account2 recordtype is defualt record type for profile...
How to solve it please any one can tell me...!

Thanks
NNR
 
  • November 29, 2014
  • Like
  • 0
list<string> rightvalues{set;get;}
  public PageReference updateMarkets(){
        oppsToCreateList.clear();
        selectedMarketsList.clear();
        selectedMarketsList.addall(rightvalues);
        system.debug('000000000000000000000'+rightvalues+selectedMarketsList);
        for (Integer i=0; i<selectedMarketsList.size(); i++){
            String themkt = selectedMarketsList.get(i);
            
            boolean alreadyAdded = false;
            //## see if the Market is already in the oppsToCreateList
            for (Opportunity tmpopp : oppsToCreateList)
            {
                if (themkt == tmpopp.opportunity_multi__c)
                {
                    alreadyAdded = true;
                }   
            }
            
            if (themkt == opp.opportunity_multi__c || alreadyAdded)
            {
                //## don't re-add the original opp to the list, and don't
                //## add the same record to the list multiple times.
            }
            else
            {
                Opportunity newopp = opp.clone(false);
                Newopp.OrderNumber__c = themkt;
                newopp.accountid=acc.id;
                newopp.ownerId=UserInfo.getUserId();
                newopp.stagename='1 - Prospect Evaluation';
                newopp.closedate=date.today();
                newopp.Name =acc.name;
                oppsToCreateList.add(newopp);
   
            }
            
        }
        
      system.debug('1111111111111111111111111111111111111'+oppsToCreateList);
     return null;
       
   }
   public PageReference  SaveRecords(){
      if (oppsToCreateList != null && oppsToCreateList.size() > 0)
        {
            try
            {       
                insert oppsToCreateList;
            }
            catch (Exception e)
            {
                ApexPages.addMessages(e);
                return null;        
            }
        }
      return new PageReference('/'+acc.Id);
   }

}
 
  • November 19, 2014
  • Like
  • 0
public PageReference exportData()
    {
        String ssql;
        pageReference pg = null;
        String header = setFieldHeader(true);      
            
        if(!String.isEmpty(header))          
        {               
            fieldHeader = header;
            if(exportEncodingType == 'Unicode') {
                fieldHeader = EncodingUtil.convertFromHex('EFBBBF').toString() + fieldHeader;
            }
            system.debug('???selectedObjectName'+selectedObjectName);
            if (selectedObjectName == 'GSD_Resource_Skill__c') {
                fieldList.add('Resource__r.CKSW__ID__c');
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c WHERE Resource__r.CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c WHERE Resource__r.CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c LIMIT 50000';
                }
            } else if (selectedObjectName == 'CKSW__Engineer_Equipment__c') {                
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c WHERE CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c WHERE CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c LIMIT 50000';
                }
            }  else if (selectedObjectName == 'GSD_Resource_District__c') {
                fieldList.add('Resource__r.CKSW__ID__c');                
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c WHERE Resource__r.CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c WHERE Resource__r.CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c LIMIT 50000';
                }                               
            } else if (selectedObjectName == 'GSD_Resource_District_Mapping__c') {
               // fieldList.add('GSD_Resource__r.First_name__c');
               // fieldList.add('GSD_Resource__r.Last_name__c');
                
                Integer index1 = 0;
                for(String strList : fieldList) {
                    if(strList == 'GSD_Resource__r.Name') fieldList[index1] = 'GSD_Resource__r.User__r.Name';                 
                    index1++;
                }              
                fieldList.add('GSD_Resource__r.Employee_ID__c');               
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c WHERE GSD_Resource__r.Country_ISO__r.name In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c WHERE GSD_Resource__r.Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c LIMIT 50000';
                }
            } else if (selectedObjectName == 'GSD_Resource_Skills_mapping__c') {         
                Integer index = 0;
                for(String strList : fieldList) {
                    if(strList == 'Resource_ID__r.Name') fieldList[index] = 'Resource_ID__r.User__r.Name';                 
                    index++;
                }                               
                fieldList.add('Resource_ID__r.employee_id__c');                 
                if (filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c WHERE Resource_ID__r.Country_ISO__r.name In (\'' + String.join(CurrentList, '\',\'') + '\')  AND Web_App_Employee_Id__c = \''+'\' LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c WHERE Resource_ID__r.Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') AND Web_App_Employee_Id__c = \''+'\' LIMIT 50000';
                }
                else {                                
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c LIMIT 50000';              
                }                           
            } else if (selectedObjectName == 'GSD_Resource__c') {
                List<String> templist = new List<String>();             
                templist.add(fieldlist[0]);             
                templist.add('User__r.Legacy_Employee_Ref__c');
                fieldList[1] = 'User__r.Name';
                fieldlist.remove(0);
                templist.addAll(fieldlist);
                fieldlist = templist;
                /*Integer index = 0;
                for(String strList : fieldList) {
                    if(strList == 'Employee_ID__c') fieldList[index] = 'User__r.Name';                 
                    index++;
                }           
                fieldList.add('User__r.Legacy_Employee_Ref__c');*/
                if (filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c WHERE Country_ISO__r.Name In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c WHERE Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c LIMIT 50000';                           
                }
            }
            system.debug('??? fieldList......'+fieldList);
            system.debug('??? query structure...'+ssql);
            
            objLst = new List < sObject > ();
            ListobjLst = new List <List<sObject>> ();  
            for (sobject s: Database.Query(ssql)) {
                   objLst.add(s);
                if (objLst.size() == 1000) { //limit of vf repeat components
                    ListobjLst.add(objLst);
                    objLst = new List < sobject > ();
                }
            }
            ListobjLst.add(objLst);
            pg = new pageReference('/apex/GSDBulkTemplate');
            pg.setRedirect(false);
        }        
        return pg;
    }
  • March 01, 2015
  • Like
  • 1
Q: I creat custom button on Opportunity name:display
if click on Display 1.if any contacts is there went to contacts view page
                             2.no contacts show error msg

How to do it.
  • October 15, 2014
  • Like
  • 1



I have a requirement that there is a user with particular profile and if he logs into the salesforce account, I want that he should be directly shifted to a visual force page.
  • March 13, 2014
  • Like
  • 1
I set up a duplicate record rule that says Allow duplicate records.  I have a custom controller extension that calls the Standard Controller as follows when the user hits the Save button:
PageReference pRef = baseController.save();
return pRef;
The pRef is "null" when the record I'm trying to save is a duplicate, according to my rule.  When the page is displayed the error says "Error: There is already a contact in this account with the same email. But you may create this new one anyway."  (This is my text for the duplicate alert message).

But every time baseController.save() gets called it returns this error.  How can I implement the functionality that the second time you click Save it will create the new record anyway?
Hi,
   How to Create Custom Button to Send Email to a Specific Email ,Please explain with code
HI All:  i have one scenario
Oppoerunity is closed/won then we need to create one child Record for Opportunity.we are captruring Closed/won date.
when closed/won date (28/8/2015) then user within 10days(8/9/2015) user unable to create child record send email to salesmanagaer.
In mail we need send minimum oppoerutnity details to salesmanager
How can i do it ?help me out
  • August 28, 2015
  • Like
  • 0
Hi All,
plz help me out...

public pagerefernce Accnext(){
 if(Secondary.Guardian_Name__c!=null &&((Secondary.Guardian_Age__c< 18)||(Secondary.Guardian_Age__c==null))){            AddError('Error: Guardian Age should be greater than equals to 18 ');
           return null;
    }
   else{
              try{ Account.Sex__c='F';Upsert(Account);            if( (Secondary.Relationdhip_with_Secondary_Customer__c=='Brother') || (Secondary.Relationdhip_with_Secondary_Customer__c=='Father')                 || (Secondary.Relationdhip_with_Secondary_Customer__c=='Fathein-law') || (Secondary.Relationdhip_with_Secondary_Customer__c=='Husband')                || (Secondary.Relationdhip_with_Secondary_Customer__c=='Son')){
                   Secondary.Gender__c='M';
           }
               Secondary.Account__c= Account.id;
                upsert(Secondary);
               nextTabValue = 'ContactDetails';               
              // adding primary customer into family member
                wrappers[0].name=Account.name;wrappers[0].Gender__c=Account.Sex__c;wrappers[0].Education__c=Account.Education1__c;                 wrappers[0].Marital_Status__c=Account.Marital_Status__c;                 if(Account.Natureofemployment__c=='Self- Employed' || Account.Natureofemployment__c=='Salaried'){                     wrappers[0].Occupation_Types__c='Employed';                 }                else if(Account.Natureofemployment__c=='Not-Employed' &&((Account.Type_of_Employment__c=='House wife') ||(Account.Type_of_Employment__c=='Others'))){                   wrappers[0].Occupation_Types__c='Not Employed';                }                else{                    wrappers[0].Occupation_Types__c='Student';                }                //=========================================================================               // Adding Secondary customer details into family member             if(Secondary.Relationdhip_with_Secondary_Customer__c!='Group Member' && Secondary.Type_of_Relation__c !='Group Member'){                  wrappers[1].name=Secondary.Name;                  wrappers[1].Gender__c=Secondary.Gender__c;                  wrappers[1].Education__c=Secondary.Educations__c;                  wrappers[1].Marital_Status__c=Secondary.Marital_Statuss__c;                  if(Secondary.Nature_of_Employment__c=='Self-Employed' || Secondary.Nature_of_Employment__c=='salaried'){                         wrappers[1].Occupation_Types__c='Employed';                  }                  else if(Secondary.Nature_of_Employment__c=='Not-Employed' &&((Secondary.Type_of_Employment__c=='House wife') ||(Secondary.Type_of_Employment__c=='Others'))){                      wrappers[1].Occupation_Types__c='Not Employed';                  }                  else{                       wrappers[1].Occupation_Types__c='Student';                  }            }
 


Thanks in Advance....
  • March 30, 2015
  • Like
  • 0
HI All,
please help me out for the bellow method how to write test class.

   public void delWrapper(){
   
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));         system.debug('rowNum '+rowNum );         wrappers.remove(rowNum);  // here wrappers is pageblockTable method     
        system.debug('wrappers&&&&&&&&&&'+wrappers);        
        lstacc1 =[Select id,Name from Family__c where id=:dcid];         
         system.debug('lstacc1'+lstacc1 );        
        delete lstacc1;
}
IN test class it showing Error ::Arguments can not be null;
test class
obj.rowNum = Integer.valueOf(apexpages.currentpage().getparameters().put('index','1'));
obj.delWrapper();// calling method from test clss

2.constructor.

  Public deosearchpage(){
   AccountID=apexpages.currentpage().getparameters().get('accId');
  if(AccountID!=null){
try{
     Acc=[select id ,name from account where id=:AccountID];
   }
catche(){

  }
}
}
HOw to write test class for above once also
  • March 29, 2015
  • Like
  • 0
Hi All plz tell me how to write test class for bellow method


public PageReference AccNext() {                  if(Account.CIS_No_new__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter CIS number');            ApexPages.addMessage(msg);             if(!test.isrunningTest())            return null;         }         if(Account.Salutation__c == Null){           ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Salutation for primary customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;          }         if(Account.LastName__c== Null){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Primary customer Lastname');            ApexPages.addMessage(msg);             if(!test.isrunningTest())            return null;         }                       //====================== new logic added for salutation and gender matching for Primary/Secondary Customer=====================         if(Account.Sex__c != Null && Account.salutation__c != Null && Account.salutation__c == 'Mrs.' && Account.Sex__c == 'M'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Female under Primary Customer Details');            ApexPages.addMessage(msg);                if(!test.isrunningTest())            return null;                  }         if(Account.Sex__c != Null && Account.salutation__c != Null && Account.salutation__c == 'Mr.' && Account.Sex__c == 'F'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Male under Primary Customer Details');            ApexPages.addMessage(msg);                if(!test.isrunningTest())            return null;                  }        if(Account.Sex__c != Null && Account.salutation__c != Null && Account.salutation__c == 'Ms' && Account.Sex__c == 'M'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Female under Primary Customer Details');            ApexPages.addMessage(msg);                if(!test.isrunningTest())            return null;                  }                                    //========================================= end of new logic ===============================================================================================         if(Account.Marital_Status__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer marital status');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Account.Education1__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer Education');            ApexPages.addMessage(msg);             if(!test.isrunningTest())             return null;                  }                  if(Account.IdentityProof__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer ID type1');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Account.IdentityProofNo__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer Identity No');            ApexPages.addMessage(msg);              if(!test.isrunningTest())           return null;                  }         //updated for new id proof details         if(Account.IdentityProof_coborr__c==Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer ID type2');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Account.IdentityProofNo1__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter primary customer Identity No2');            ApexPages.addMessage(msg);              if(!test.isrunningTest())           return null;                  }// updation end -         if(Account.Aadhar_Card__c=='Yes' && (Account.Aadhar_Card_No__c==null || Account.Aadhar_Card_No__c=='')){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Aadhar card Number');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Secondary.Name== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer First name');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Secondary.Last_Name__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer Last name');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Secondary.Salutation__c == Null)         {           ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Salutation for secondary customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;          }          if(Account.Name == Secondary.Name && Account.LastName__c ==   Secondary.Last_Name__c){             ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Primary and Secondary customer name should not be same');            ApexPages.addMessage(msg);              if(!test.isrunningTest())           return null;         }         if(Secondary.Date_of_Birtht__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary Customer Date of Birth');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(((Secondary.FH_FirstName__c == Null || Secondary.FH_LastNames__c == Null) && (Secondary.Spouse_First_Name_SC__c== Null || Secondary.Spouse_Last_Name_SC__c == Null)) && Account.Opted_for_NPS_Lite__c == 'No')  {            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Fathers/Spouse first name and last name of Secondary Customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;                  }                  if( (Secondary.FH_FirstName__c== Null || Secondary.FH_LastNames__c == Null)&& Account.Opted_for_NPS_Lite__c == 'Yes'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Fathers first and last name of Secondary customer');            ApexPages.addMessage(msg);                if(!test.isrunningTest())             return null;                  }         /*  Logi for Gender and Salutation  */         if(Secondary.Gender__c != Null && Secondary.Salutation__c != Null && Secondary.Salutation__c == 'Mr.' && Secondary.Gender__c == 'F'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Male under Secondary Customer Details');            ApexPages.addMessage(msg);             if(!test.isrunningTest())            return null;                     }           if(Secondary.Gender__c != Null && Secondary.Salutation__c != Null && Secondary.Salutation__c == 'Mrs.' && Secondary.Gender__c == 'M'){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please change the Gender to Female under Secondary Customer Details');            ApexPages.addMessage(Msg);             if(!test.isrunningTest())            return null;                     }                            if(Secondary.Marital_Statuss__c== Null ){                 ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Secondary customer Marital Status');                 ApexPages.addMessage(msg);                 if(!test.isrunningTest())                  return null;             }         */          if(Secondary.Educations__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer Education');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Secondary.Identity_Proofs__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer ID Type');            ApexPages.addMessage(msg);             if(!test.isrunningTest())             return null;                  }         if(Secondary.Identity_ProofNo__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Secondary customer Identity Proof No');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Secondary.Gender__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Secondary customer SEX');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Secondary.Nature_of_Employment__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Secondary customer Nature of Employement');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }          if(Account.Caste__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please enter Caste');            ApexPages.addMessage(msg);              if(!test.isrunningTest())            return null;                  }         if(Account.Religion__c== Null ){            ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Please select Religion');            ApexPages.addMessage(msg);             if(!test.isrunningTest())             return null;                  }                     else         {                       try{                                  Upsert(Account);                 Account StdaccListfmly = new Account();                             RecordType SecondaryRt= [SELECT DeveloperName,Id,Name FROM RecordType where DeveloperName='For_DEO' and sobjectType='Secondary_Customer_Details__c'];                                  Secondary.RecordtypeId=SecondaryRt.Id;                 StdaccListfmly=[Select id, Name,Age_of_Borrower1__c,Natureofemployment__c from Account where Id =:account.Id limit 1];                 Secondary.Account__c= StdaccListfmly.id;                 upsert(Secondary);//Database.upsert(Secondary); commented by bhanu to catch dml exception - 3 dec                 Secondary_Customer_Details__c SecListfmly = new Secondary_Customer_Details__c();                 SecListfmly=[Select id,Nature_of_Employment__c,Type_of_Relation__c,Length_of_Business_Service_Years__c ,Relationdhip_with_Secondary_Customer__c,Name,Age_of_Co_Borrower__c from Secondary_Customer_Details__c where Id =:Secondary.Id limit 1];                 system.debug('**********Relationdhip_with_Secondary_Customer__c***********'+SecListfmly.Relationdhip_with_Secondary_Customer__c);                 system.debug('**********Type_of_Relation__c***********'+SecListfmly.Type_of_Relation__c);                 String nextTabValue = 'ContactDetails';                   if(nextTabValue != null){                    currentTab = nextTabValue;                         Opportunity.Account__c= account.id;                      Opportunity.Secondary_Customer_Details__c=secondary.Id;                                                          }            }            catch(DmlException e){                 ApexPages.addMessages(e);                 LogsExceptionClass.insertLog(e.getMessage(),e.getLineNumber(),e.getTypeName(),String.valueOf(e.getcause()),e.getStackTraceString());            }        }        return null;     }

 
  • March 06, 2015
  • Like
  • 0
public PageReference exportData()
    {
        String ssql;
        pageReference pg = null;
        String header = setFieldHeader(true);      
            
        if(!String.isEmpty(header))          
        {               
            fieldHeader = header;
            if(exportEncodingType == 'Unicode') {
                fieldHeader = EncodingUtil.convertFromHex('EFBBBF').toString() + fieldHeader;
            }
            system.debug('???selectedObjectName'+selectedObjectName);
            if (selectedObjectName == 'GSD_Resource_Skill__c') {
                fieldList.add('Resource__r.CKSW__ID__c');
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c WHERE Resource__r.CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c WHERE Resource__r.CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skill__c LIMIT 50000';
                }
            } else if (selectedObjectName == 'CKSW__Engineer_Equipment__c') {                
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c WHERE CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c WHERE CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM CKSW__Engineer_Equipment__c LIMIT 50000';
                }
            }  else if (selectedObjectName == 'GSD_Resource_District__c') {
                fieldList.add('Resource__r.CKSW__ID__c');                
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c WHERE Resource__r.CKSW__COUNTRY__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c WHERE Resource__r.CKSW__District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District__c LIMIT 50000';
                }                               
            } else if (selectedObjectName == 'GSD_Resource_District_Mapping__c') {
               // fieldList.add('GSD_Resource__r.First_name__c');
               // fieldList.add('GSD_Resource__r.Last_name__c');
                
                Integer index1 = 0;
                for(String strList : fieldList) {
                    if(strList == 'GSD_Resource__r.Name') fieldList[index1] = 'GSD_Resource__r.User__r.Name';                 
                    index1++;
                }              
                fieldList.add('GSD_Resource__r.Employee_ID__c');               
                if (CurrentList != null && CurrentList.size() > 0 && filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c WHERE GSD_Resource__r.Country_ISO__r.name In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c WHERE GSD_Resource__r.Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_District_Mapping__c LIMIT 50000';
                }
            } else if (selectedObjectName == 'GSD_Resource_Skills_mapping__c') {         
                Integer index = 0;
                for(String strList : fieldList) {
                    if(strList == 'Resource_ID__r.Name') fieldList[index] = 'Resource_ID__r.User__r.Name';                 
                    index++;
                }                               
                fieldList.add('Resource_ID__r.employee_id__c');                 
                if (filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c WHERE Resource_ID__r.Country_ISO__r.name In (\'' + String.join(CurrentList, '\',\'') + '\')  AND Web_App_Employee_Id__c = \''+'\' LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c WHERE Resource_ID__r.Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') AND Web_App_Employee_Id__c = \''+'\' LIMIT 50000';
                }
                else {                                
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource_Skills_mapping__c LIMIT 50000';              
                }                           
            } else if (selectedObjectName == 'GSD_Resource__c') {
                List<String> templist = new List<String>();             
                templist.add(fieldlist[0]);             
                templist.add('User__r.Legacy_Employee_Ref__c');
                fieldList[1] = 'User__r.Name';
                fieldlist.remove(0);
                templist.addAll(fieldlist);
                fieldlist = templist;
                /*Integer index = 0;
                for(String strList : fieldList) {
                    if(strList == 'Employee_ID__c') fieldList[index] = 'User__r.Name';                 
                    index++;
                }           
                fieldList.add('User__r.Legacy_Employee_Ref__c');*/
                if (filterOption == 'country') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c WHERE Country_ISO__r.Name In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else if (filterOption == 'district') {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c WHERE Primary_District__c In (\'' + String.join(CurrentList, '\',\'') + '\') LIMIT 50000';
                } else {
                    ssql = 'Select ' + String.join(fieldList, ',') + ' FROM GSD_Resource__c LIMIT 50000';                           
                }
            }
            system.debug('??? fieldList......'+fieldList);
            system.debug('??? query structure...'+ssql);
            
            objLst = new List < sObject > ();
            ListobjLst = new List <List<sObject>> ();  
            for (sobject s: Database.Query(ssql)) {
                   objLst.add(s);
                if (objLst.size() == 1000) { //limit of vf repeat components
                    ListobjLst.add(objLst);
                    objLst = new List < sobject > ();
                }
            }
            ListobjLst.add(objLst);
            pg = new pageReference('/apex/GSDBulkTemplate');
            pg.setRedirect(false);
        }        
        return pg;
    }
  • March 01, 2015
  • Like
  • 1
hi,
one checkbox is on my vf when this checkbox enable then related incident must be changed there status
plz can you me the solution ,how to assign status to this checkbox
Hi fnds...

 Iam 401(SU-14) Certified Developer and when i write for maintance exam and how can i check if any maintance exams available or not..

Maintaince exams are free or chargeable
plz help me out

Regards
NNR
  • January 06, 2015
  • Like
  • 0
Hi Fnds..

 In my organation i have one profile is CanadaUsers, i have send a Email to user's Reset your password with link.

Example:: Adminin can send individuals user's resetpassword link when click on Resetpassword button on profile and check the checkbox for user

like above i can send emails to all user's in particular profile


Thanks in Advance
Nnr
 
  • December 27, 2014
  • Like
  • 0
list<string> rightvalues{set;get;}
  public PageReference updateMarkets(){
        oppsToCreateList.clear();
        selectedMarketsList.clear();
        selectedMarketsList.addall(rightvalues);
        system.debug('000000000000000000000'+rightvalues+selectedMarketsList);
        for (Integer i=0; i<selectedMarketsList.size(); i++){
            String themkt = selectedMarketsList.get(i);
            
            boolean alreadyAdded = false;
            //## see if the Market is already in the oppsToCreateList
            for (Opportunity tmpopp : oppsToCreateList)
            {
                if (themkt == tmpopp.opportunity_multi__c)
                {
                    alreadyAdded = true;
                }   
            }
            
            if (themkt == opp.opportunity_multi__c || alreadyAdded)
            {
                //## don't re-add the original opp to the list, and don't
                //## add the same record to the list multiple times.
            }
            else
            {
                Opportunity newopp = opp.clone(false);
                Newopp.OrderNumber__c = themkt;
                newopp.accountid=acc.id;
                newopp.ownerId=UserInfo.getUserId();
                newopp.stagename='1 - Prospect Evaluation';
                newopp.closedate=date.today();
                newopp.Name =acc.name;
                oppsToCreateList.add(newopp);
   
            }
            
        }
        
      system.debug('1111111111111111111111111111111111111'+oppsToCreateList);
     return null;
       
   }
   public PageReference  SaveRecords(){
      if (oppsToCreateList != null && oppsToCreateList.size() > 0)
        {
            try
            {       
                insert oppsToCreateList;
            }
            catch (Exception e)
            {
                ApexPages.addMessages(e);
                return null;        
            }
        }
      return new PageReference('/'+acc.Id);
   }

}
 
  • November 19, 2014
  • Like
  • 0
Hi frnds can you help me out...!
below i write test class but it gives only 70% how to increase more than 75%
code in "bold" is not include in code coverage
==================controller==================
public with sharing class multipleRecordsOnOpportunity {
    Public List<string> leftselected{get;set;}
    public List<String> selectedMarketsList {get; set;}
    Public List<string> rightselected{get;set;}
    public list<selectoption> getPickLstValue(){return null;}
    public Set<String> originalvalues = new Set<String>{'A','B','C','D','E','F','G','H','I'};
    public set<string> leftvalues = new set<string>();
    public set<string> rightvalues = new set<string>();
    public account acc{set;get;}
    public opportunity opp {set;get;}
    public boolean flag{set;get;}
    public list<opportunity> oppsToCreateList{set;get;}
    // constructor  
    public multipleRecordsOnOpportunity(ApexPages.StandardController controller) {
          opp= new opportunity();
          leftselected = new List<String>();
          rightselected = new List<String>();
          leftvalues.addall(originalvalues );
          selectedMarketsList= new list<string>();
          oppsToCreateList=new list<Opportunity>();
          rightselected = new List<String>();
          string str=ApexPages.CurrentPage().getParameters().get('id');
          system.debug('99999999999999999999999999999'+str);
          try{
             acc=[select id,name,CustomerPriority__c from account where id=:str limit 1];
             if(acc.CustomerPriority__c=='High'|| acc.CustomerPriority__c=='Medium'){
                flag=true;
             }
             else{
                 ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Multiple Opportunities can only be created from High and medium from parent account.');
                ApexPages.addMessage(myMsg);
             }
          }
          catch(Exception e){
            ApexPages.addMessages(e);
          }
    }
     
     
    // after click on add buttone display vlaues in Right side panel
    public List<SelectOption> getSelectedValues(){

        List<SelectOption> options1 = new List<SelectOption>();

        List<string> tempList = new List<String>();

        tempList.addAll(rightvalues);

        tempList.sort();

        for(String s : tempList)

            options1.add(new SelectOption(s,s));
            system.debug('1111111111111111111111'+options1);

        return options1;

    }
    
    // by defult left side values or after click on remove values in left panel
    public List<SelectOption> getunselectedvalues(){
           List<SelectOption> options = new List<SelectOption>();
           /*Schema.DescribeFieldResult fieldResult = opportunity.opportunity_multi__c.getDescribe();
           List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
           for(Schema.PicklistEntry f : ple){
              if(f.getValue() != 'A' && f.getValue() != 'b' ){
                     options.add(new SelectOption(f.getLabel(), f.getValue()));
              }
          }*/


        List<string> tempList = new List<String>();

        tempList.addAll(leftvalues);

        tempList.sort();

        for(string s : tempList)

            options.add(new SelectOption(s,s));
            system.debug('00000000000000000000000000000'+options);
       
          return options;           
   }
   // aaction function of add button add values in right side
   public PageReference selectclick(){

        rightselected.clear();

        for(String s : leftselected){

            leftvalues.remove(s);

            rightvalues.add(s);

        }
        system.debug('22222222222222222222222'+leftvalues);
        system.debug('33333333333333333333333'+rightvalues);

        return null;

    }
    // after click on Remove button display vlaues in panel
    public PageReference unselectclick(){

        leftselected.clear();

        for(String s : rightselected){

            rightvalues.remove(s);

            leftvalues.add(s);

        }
        system.debug('4444444444444444444444444'+leftvalues);
        system.debug('5555555555555555555555555'+rightvalues);


        return null;

    }
    // clone Records Based number of markets selecting(Ex:selecting c,d,e clones 3 records)
   public PageReference updateMarkets(){
        oppsToCreateList.clear();
        selectedMarketsList.clear();
        selectedMarketsList.addall(rightvalues);
        system.debug('000000000000000000000'+rightvalues+selectedMarketsList);
        for (Integer i=0; i<selectedMarketsList.size(); i++){
            String themkt = selectedMarketsList.get(i);
            
            boolean alreadyAdded = false;
            //## see if the Market is already in the oppsToCreateList
            for (Opportunity tmpopp : oppsToCreateList)
            {
                if (themkt == tmpopp.opportunity_multi__c)
                {
                    alreadyAdded = true;
                }   
            }
            
            if (themkt == opp.opportunity_multi__c || alreadyAdded)
            {
                //## don't re-add the original opp to the list, and don't
                //## add the same record to the list multiple times.
            }
            else
            {
                Opportunity newopp = opp.clone(false);
                Newopp.OrderNumber__c = themkt;
                newopp.accountid=acc.id;
                newopp.ownerId=UserInfo.getUserId();
                newopp.stagename='1 - Prospect Evaluation';
                newopp.closedate=date.today();
                newopp.Name =acc.name;
                oppsToCreateList.add(newopp);
   
            }
       
     
        }
        
      system.debug('1111111111111111111111111111111111111'+oppsToCreateList);
     return null;
       
   }
   public PageReference  SaveRecords(){
      if (oppsToCreateList != null && oppsToCreateList.size() > 0)
        {
            try
            {       
                insert oppsToCreateList;
            }
            catch (Exception e)
            {
                ApexPages.addMessages(e);
                return null;        
            }
    
    }
      return new PageReference('/'+acc.Id);
   }

}

==============Test class=============================================
@isTest()
public class TestmultipleRecordsOnOpportunity{
   static testMethod void myUnitTest_creat_multiple_Opportunity()
    {
     // This method for successful adding Multiple OpportunityRecords to Account
      Account a1 = new Account();
      a1.Name = 'testa1';
      a1.CustomerPriority__c ='mp';
      insert a1;// Creating Mock Data For Account
      Opportunity o1 = new Opportunity();
      o1.Name = 'testo1prodprodprodprodprodprodprodprodprodprodprodprodprodprodprodprodprodprodprodprodprodprod';
      o1.AccountId = a1.Id;
      o1.StageName = 'test';
      o1.CloseDate = Date.today();
      o1.Amount = 100000000;
      insert o1;// Creating Mock Date For Opportunity
      Test.startTest();
        PageReference pageRef = new PageReference('/apex/multipleRecordsOnOpportunity?id='+a1.Id);
        Test.setCurrentPageReference(pageRef);
        
        //Adding visualforce page multipleRecordsOnOpportunity  To Testclass
        ApexPages.StandardController sc =new ApexPages.StandardController(a1);// Initializing Standard Controller
        multipleRecordsOnOpportunity  myPageCon =new multipleRecordsOnOpportunity (sc);// Adding Extension to Standard controller
        List<SelectOption> testoptions1=myPageCon.getunselectedvalues();
        myPagecon.selectclick();
        list<SelectOption> testoptions=myPageCon.getSelectedValues();
        mypagecon.unselectclick();
        List<SelectOption> testoptions11=myPageCon.getunselectedvalues();
        myPagecon.selectclick();
        list<SelectOption> testoptionss=myPageCon.getSelectedValues();
        list<String> originalvalues = new list<String>{'A','B','C'};
        myPageCon.updateMarkets();// calling method updateMarkets
        myPageCon.selectedMarketsList=originalvalues ;
        myPageCon.updateMarkets();// calling method updateMarkets checking loop conditons
        myPageCon.SaveRecords();// calling method newRecordsInsertMethod
      Test.stopTest();
      
    }
      static testMethod void myUnitTest_creat_multiple_Opportunity1()
    {
     // This method for successful adding Multiple OpportunityRecords to Account
      Account a1 = new Account();
      a1.Name = 'testa1';
      a1.CustomerPriority__c='medium';
      insert a1;// Creating Mock Data For Account
      Opportunity o1 = new Opportunity();
      o1.Name = 'testo1prodprodprodprodprodprodprodprodprodprodprodprodprodprodprodprodprodprodprodprodprodprod';
      o1.AccountId = a1.Id;
      o1.StageName = 'test';
      o1.CloseDate = Date.today();
      o1.Amount = 100000000;
      insert o1;// Creating Mock Date For Opportunity
      Test.startTest();
        PageReference pageRef = new PageReference('/apex/multipleRecordsOnOpportunity ?id='+a1.Id);
        Test.setCurrentPageReference(pageRef);
        //Adding visualforce page multipleRecordsOnOpportunity  To Testclass
        ApexPages.StandardController sc =new ApexPages.StandardController(a1);// Initializing Standard Controller
        multipleRecordsOnOpportunity  myPageCon =new multipleRecordsOnOpportunity (sc);// Adding Extension to Standard controller
       list<SelectOption> testoptions=myPageCon.getSelectedValues();
        List<SelectOption> testoptions1=myPageCon.getunselectedvalues();
        myPagecon.selectclick();
        mypagecon.unselectclick();
        list<String> originalvalues = new list<String>{'A','B','C','D','E','F','G','H','I'};
        myPageCon.updateMarkets();// calling method updateMarkets
        myPageCon.selectedMarketsList=originalvalues ;
        myPageCon.updateMarkets();// calling method updateMarkets checking loop conditons
        myPageCon.SaveRecords();// calling method newRecordsInsertMethod
      Test.stopTest();
      
    }
   static testMethod void myUnitTest_MassCloneFail()
    {
         
        Account a1 = new Account();
        a1.Name = 'testa1';
        a1.CustomerPriority__c='High';
        insert a1;
        
        Opportunity o1 = new Opportunity();
        o1.Name = 'testo1';
        o1.AccountId = a1.Id;
        o1.StageName = 'test';
        o1.CloseDate = Date.today();
        o1.Amount = 100;
        
        insert o1;
        
        Test.startTest();
        
        PageReference pageRef = new PageReference('/apex/multipleRecordsOnOpportunity ?id='+a1.Id);
        Test.setCurrentPageReference(pageRef);
        // create an instance of the controller
        ApexPages.StandardController sc =
                new ApexPages.StandardController(o1);
        multipleRecordsOnOpportunity  myPageCon = new multipleRecordsOnOpportunity (sc);
        list<SelectOption> testoptions=myPageCon.getSelectedValues();
        List<SelectOption> testoptions1=myPageCon.getunselectedvalues();
        myPagecon.selectclick();
        mypagecon.unselectclick();
        list<String> originalvalues = new list<String>{'A','B','C','D','E','F','G','H','I'};
        myPageCon.selectedMarketsList =originalvalues ;
        myPageCon.updateMarkets();
        
        myPageCon.opp.Name = '';
        myPageCon.SaveRecords();
        
        myPageCon.opp.Name = '';
        myPageCon.SaveRecords();
        
               
        Test.stopTest();
        
    }   
    static testMethod void myUnitTest_MassCloneFail1()
    {
         
        Account a1 = new Account();
        a1.Name = 'testa1';
        a1.CustomerPriority__c='low';
        insert a1;
        
        Opportunity o1 = new Opportunity();
        o1.Name = 'testo1';
        o1.AccountId = a1.Id;
        o1.StageName = 'test';
        o1.CloseDate = Date.today();
        o1.Amount = 100;
        
        insert o1;
        
        Test.startTest();
        
        PageReference pageRef = new PageReference('/apex/multipleRecordsOnOpportunity ?id='+null);
        Test.setCurrentPageReference(pageRef);
        // create an instance of the controller
        ApexPages.StandardController sc =
                new ApexPages.StandardController(o1);
        multipleRecordsOnOpportunity  myPageCon = new multipleRecordsOnOpportunity (sc);
       //myPageCon.selectedMarketsList= 'UK;France';
        list<SelectOption> testoptions=myPageCon.getSelectedValues();
        List<SelectOption> testoptions1=myPageCon.getunselectedvalues();
        myPagecon.selectclick();
        mypagecon.unselectclick();
        myPageCon.opp.Name = '';
        myPageCon.SaveRecords();
        
        myPageCon.opp.Name = '';
        myPageCon.SaveRecords();
        
               
        Test.stopTest();
        
    }   

}
  • November 16, 2014
  • Like
  • 0
HI plz help how to achive good coverage for below class
Standard contoller="ACCOUNT"  Extension ="Create_Multiple"

public class Create_Multiple{
    public Opportunity  {get; set;}
    public Account acc{get; set;}
    public string  mal{set;get;}
    public String marketsString {get; set;}
    public List<String> selectedMarketsList {get; set;}
    public Create_Multiple(ApexPages.StandardController opp){
         oppLocal= new Opportunity();
         oppsToCreateList=new list<Opportunity>();
         mal=ApexPages.CurrentPage().getParameters().get('id');
         system.debug('AAAAAAAAAAAAAAAACCCCCCCCCCCCCOunt'+mal);
         acc=[select id,name,CP_Hierarchy__c from account where id=:mal];
    }
    
    public PageReference generateAllClones(){
        marketsString = oppLocal.Opportunity_Markets__c;
        selectedMarketsList = new List<String>();
        if (Utility.isNotNull(marketsString))
        {
            selectedMarketsList = marketsString.split(';');
        }
        
        //oppsToCreateList.add(oppLocal);
        
        //## iterate over the selected markets and create an Opp for each one...
        for (Integer i=0; i<selectedMarketsList.size(); i++)
        {
            String themkt = selectedMarketsList.get(i);
            
            boolean alreadyAdded = false;
            //## see if the Market is already in the oppsToCreateList
            for (Opportunity tmpopp : oppsToCreateList)
            {
                if (themkt == tmpopp.Opportunity_Market__c)
                {
                    alreadyAdded = true;
                }   
            }
            
            if (themkt == oppLocal.Opportunity_Market__c || alreadyAdded)
            {
                //## don't re-add the original opp to the list, and don't
                //## add the same record to the list multiple times.
            }
            else
            {
                Opportunity newopp = oppLocal.clone(false);
                String thenom = acc.Name;
                //thenom = thenom + ' - ' + themkt;
                newopp.Opportunity_Market__c = themkt;
                newopp.accountid=mal;
                newopp.stagename='1 - Prospect Evaluation';
                newopp.closedate=date.today();
                newopp.RecordTypeId='012Z000000096eo';

                if (thenom.length() > 80)
                {
                    thenom = thenom.substring(0,80);
                }
                newopp.Name = acc.Name;
                
                
                oppsToCreateList.add(newopp);
                
            }
            
        }
        

        return null;
  }
  public PageReference doOppClone()
    {
        
System.Debug('    oppsToCreate:'+oppsToCreateList);
        if (oppsToCreateList != null && oppsToCreateList.size() > 0)
        {
            try
            {       
                insert oppsToCreateList;
            }
            catch (Exception e)
            {
                ApexPages.addMessages(e);
                return null;        
            }
        }
        return  new PageReference('/'+acc.Id);
    }
 
  public List<Opportunity> oppsToCreateList {get;set;}
}
  • November 07, 2014
  • Like
  • 0
Hi all,
plz help me out...

Q: i created custom button on lead is name NNR it's override with visualforce page,but this visualforce page can access only Roles and profiles
Role name is ='High level authority '
  • November 06, 2014
  • Like
  • 0
Q:i have created vf page with account standardcontroller and extensions,
it is possible to access fiedset of opportunity object in my vf page fieldset name is:oppfieldset

plz help me out..........................
  • November 04, 2014
  • Like
  • 0
Hi frnds I am New to write Test class plz help me out...........
My trigger ::::::::::::::::::::::::::::::::::;

trigger AddChatterGroup on User (after insert) {
    if(Trigger.Isinsert){
        for(User uids:Trigger.new){
           if(uids.nnr__c=='knr'){
               id userId = uids.id;
           asyncApex.addUserToGroup(userId);

           }
        }
  }     
}

My Apex Class:::::::::::::::::::::
global class AsyncApex {
      @future
      public static void AddUserToGroup(id userId ) {
          try {
              List<CollaborationGroupMember> CG= new List<CollaborationGroupMember>();                     
              Id cgID = [ Select Id
                          FROM CollaborationGroup
                          WHERE Name ='Nnrgroup' LIMIT 1 ].ID;
             CG.add(new CollaborationGroupMember (CollaborationGroupId = cgID, MemberId = userId));  
             insert CG;
          } catch (QueryException qe) {
              System.debug('QueryException in AsyncApex.AddUserToGroup is :' + qe);
          } catch (Exception ex) {
              System.debug('Exception in AsyncApex.AddUserToGroup is :' + ex);
          }   
      }
  }
 
  • October 29, 2014
  • Like
  • 0

I'm trying to improve the code coverage in a class that actually is 76%. In the class I have the following code that is not tested :

 

            Public List <SelectOption> buildingListOption  {get{//2&3
            List<selectOption> buildingList =new List<selectOption>();
            for(integer indx_j=0;indx_j<BuildList.size();indx_j++)
                buildingList.add(new selectOption(BuildList[indx_j].id,BuildList[indx_j].name)); 
                return buildingList;
            }//3
            private set;
            }//2
Taking out this code the coverage raised 5%. This code appears twice in the class then its weight is 10% in my code.

My question is how can I test this code.

 

Gustavo