• David Catindoy 11
  • NEWBIE
  • 15 Points
  • Member since 2014
  • Salesforce Developer
  • Cloud Sherpas, Inc.


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 13
    Replies
How can i assert for the return value of save(), Here is my code for class
public pagereference save() {

        ipAsset.AsLi_Status__c = AsLi_Constants.ASSETSTATUS_DRAFT;
        try {
            copyAccountCompanyDesc();
            upsert ipAsset;

            for(AsLi_AssetTechnology__c at : assetTechTags){
                if(at.AsLi_AssetMD__c == null){
                    at.AsLi_AssetMD__c = ipAsset.Id;
                }
            }

            upsert assetTechTags;
            
            
            PageReference IPAssetPage = new ApexPages.StandardController(ipasset).view();
                
            IPAssetPage.setRedirect(true);
            return IPAssetPage;
            
        } catch (DmlException ex) {
            ApexPages.addMessages(ex);
            return null;
        }
            
    }
Here is my test class
RecordType rt = [select id,Name from RecordType where SobjectType='AsLi_IPAsset__c' And Name = 'RFP Answer'];
        System.debug(rt);
        
        List<AsLi_TechnologiesTags__c> techTest = new List<AsLi_TechnologiesTags__c>();
        AsLi_TechnologiesTags__c tags1 = new AsLi_TechnologiesTags__c(Name = 'Google', AsLi_Active__c = True, AsLi_ForApproval__c = False);
        AsLi_TechnologiesTags__c tags2 = new AsLi_TechnologiesTags__c(Name = 'Google Talk', AsLi_Active__c = True, AsLi_ForApproval__c = False);
        AsLi_TechnologiesTags__c tags3 = new AsLi_TechnologiesTags__c(Name = 'Google Drive', AsLi_Active__c = True, AsLi_ForApproval__c = False);
        
        techTest.add(tags1);
        techTest.add(tags2);
        techTest.add(tags3);
        
        insert techTest;
        
        AsLi_IPAsset__c asset2 = new AsLi_IPAsset__c(RecordTypeId = rt.Id, Name = 'test2');
        insert asset2;
        PageReference pageRef = new PageReference('https://c.cs24.visual.force.com/apex/AsLi_AssetEdit/?Id=' + asset2.Id);



Test.setCurrentPage(pageRef);
        
        ApexPages.StandardController sCon = new ApexPages.StandardController(asset2);
        AsLi_AssetEditControllerExtension controller = new  AsLi_AssetEditControllerExtension(sCon);
        AsLi_AssetEditControllerExtension.TechnologyWrapper wr = new AsLi_AssetEditControllerExtension.TechnologyWrapper();
        controller.showPopup();
        Test.startTest();
        PageReference search1 = controller.showPopup();
        controller.searchText = 'Google';
        controller.search();
        controller.getOnFirstPage();
        controller.getOnLastPage();
        controller.add();   
        controller.save();
        Test.stopTest();
        
        
        
        System.assertEquals(3,controller.searchCount.size());
        AsLi_AssetTechnology__c assetTag = [Select Id, Name, AsLi_TechnologiesTagsMD__c, AsLi_AssetMD__c From AsLi_AssetTechnology__c];
        
        System.debug(assetTag);
        System.assertEquals(asset2.id,assetTag.AsLi_AssetMD__c);
        System.assertEquals(techTest[0].id,assetTag.AsLi_TechnologiesTagsMD__c);
        

        
    }
Hi,

Please any one guide me the procedure to stop schedule class?

Thanks in advance,
Shaik
  • December 21, 2014
  • Like
  • 0
Hi,

Please any one guide me the procedure to stop schedule class?

Thanks in advance,
Shaik
  • December 21, 2014
  • Like
  • 0
Hi,

Please any one share sample code of schedule class to execute every 15m.

Regards,
Shaik
  • December 21, 2014
  • Like
  • 0
hi i am getting this error in my trigger when i execute 100 records or so.works fine for records less than tht.

 
for(integer c=0;c<dt.size()-1;c++)
                                 {
                                     TDays=TDays+dt[c].daysBetween(dt[c+1]);
                                 }




pls help


 
trigger Accforet on Opportunity (after insert,after update) {
    List<Acc__c> AccproductList =new List<Acc__c>();
    List<Opportunitylineitem> opplinitemlist =new List<Opportunitylineitem>();
    list<opportunitylineitem > oppdate=  new list<opportunitylineitem >();
    List<Acc_Product_Fcst__c> accquery =new List<Acc_Product_Fcst__c>();
    List<date> dt =new List<date>();
    Set<Id> sProductIds = new Set<Id>();
    Set<Id> sAccountIds = new Set<Id>();
    Set<id> saccprodfcstids =new set<Id>();
    Acc__c accpro =new Acc___c();
    string aname;
    Integer i;
    Integer myIntMonth;
    Integer myIntyear;
    Integer myIntdate;
    
    opplinitemlist=[select Id,PricebookEntry.Product2.Name,opp_account__c,Opp_account_name__c,PricebookEntry.Product2.id,
                    quantity,ServiceDate,Acc_Product_Fcst__c  from Opportunitylineitem  
                    WHERE Opportunityid IN :Trigger.newMap.keySet() AND Acc_product_fcst__c=''];
    
    for(OpportunityLineItem oli:opplinitemlist) {
    sProductIds.add(oli.PricebookEntry.Product2.id);
    sAccountIds.add(oli.opp_account__c);
    //saccprodfcstids.add(oli.Acc_Product_Fcst__c);
    System.debug('************oli:'+oli);
    }
    accquery=[select id,Total_Qty_Ordered__c,Last_Order_Qty__c,Last_Order_Date__c,Fcst_Days_Period__c  from Acc__c       
              where Acc__c.product__c In :sproductids and Acc___c.Account__c in :saccountids]; 
              System.debug('*****accquery:'+accquery);
    for(Acc__c apf1 :accquery){
    saccprodfcstids.add(apf1.id);
    }        
    if(saccprodfcstids!=null){
    oppdate=[select servicedate from opportunitylineitem where Acc_Product_Fcst__c IN :saccprodfcstids ];
    
    i =[select count() from  Opportunitylineitem where acc__c in :saccprodfcstids];
    }
    
     System.debug('************Trigger.new:'+trigger.newmap.keyset());
     System.debug('************sproductsIds:'+sProductIds);
     System.debug('************saccountIds:'+sAccountIds );
     System.debug('************saccprodfcstids:'+saccprodfcstids);  
     System.debug('************accquery:'+accquery);
     System.debug('************oppdate:'+oppdate);
     system.debug('************i:'+i);
     for(Opportunity opp :trigger.new)
     {
         if(opp.Stagename=='Closed Won')
         {
                 for(opportunitylineitem opplist:opplinitemlist)
                 {
                     if(!accquery.isempty())
                     {
                         for(opportunitylineitem opldt :oppdate)
                         {
                             string myDate = String.valueOf(opldt);
                             myDate = myDate.substring(myDate.indexof('ServiceDate=')+12);
                             myDate = myDate.substring(0,10);                                    
                             String[] strDate = myDate.split('-');
                             myIntMonth = integer.valueOf(strDate[1]);
                             myIntYear = integer.valueOf(strDate[0]);
                             myIntDate = integer.valueOf(strDate[2]);
                             Date d = Date.newInstance(myIntYear, myIntMonth, myIntDate);
                             dt.add(d);
                         }  
                             dt.add(opp.closedate);
                             dt.sort();                   
                             integer TDays=0;
                                 for(integer c=0;c<dt.size()-1;c++)
                                 {
                                     system.debug('*******tdays:'+tdays);
                                     TDays=TDays+dt[c].daysBetween(dt[c+1]);
                                     system.debug('*******tdays:'+tdays);
                                     System.debug('*******dt:'+dt);
                                 }
                                 for(Acc__c apf:accquery)
                                 {
                                     apf.Fcst_Days_Period__c = TDays/i;
                                     apf.Total_Qty_Ordered__c =apf.Total_Qty_Ordered__c +opplist.quantity;
                                     apf.Last_Order_Qty__c=opplist.quantity;
                                     apf.Last_Order_Date__c=opp.CloseDate ;
                                     apf.Fcst_Qty_Avg__c=apf.Total_Qty_Ordered__c/(i+1);
                                     Opplist.Acc_Product_Fcst__c =apf.Id;  
                                 }
                                // update opplist;
                                // update accquery; 
                     }
                      
                                 else{
                                 accpro.Account__c=opplist.opp_account__c;
                                 accpro.product__c=opplist.PricebookEntry.Product2.Id;
                                 accpro.opplineitemid__c=opplist.id;
                                 accpro.Total_Qty_Ordered__c =opplist.quantity;
                                 accpro.Last_Order_Qty__c=opplist.quantity;
                                 accpro.Last_Order_Date__c=opp.CloseDate;
                                 accpro.Fcst_Qty_Avg__c=opplist.quantity;
                                 accpro.Fcst_Days_Period__c=7;
                                 accproductList.add(accpro);
                                 system.debug('********accpro:'+accpro);
                                 system.debug('********accproductlist:'+accproductlist);
                                 
                                 }
                                 insert accproductlist;
                                 }
                                 update opplinitemlist;
                                 update accquery;
             }
         }
        
     }



 
Hi,

Can we reset token by apex class. Is there method to call ..

Regards
Hi,

How to terminate schedule jobs which are in queue in schedule apex?

Regards,
Anil
Hi,
We have 1000 licenses in my org, in that few are not login regularly, I what to deactivate them automatically those are not using from last one month.

Please any one can suggest me, how can we achieve this?

Regards,
Shaik
  • December 21, 2014
  • Like
  • 0