• The new Learner
  • NEWBIE
  • 115 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 45
    Questions
  • 74
    Replies
HI Experts,

i am trying to get the difference between two dates using business hours difference method like below to exclude holidays and weeknds while converting milliseconds in to date i am not getting anything can anyone help please.
 
here is method


 long temp= BusinessHours.diff(
                            ri.Completion_Date__c,
                            ri.Completion_Date__c-3,
                            businessHoursId);

output: DEBUG|temp-1020 

DateTime gmtDatetime = DateTime.newInstance(temp);

output: gmtDatetime1969-12-31 23:59:58

 
HI Experts,

I Have requirment ,where i need to find out the businessday between two days, eg: if startdate is today, and startday-3, i need to find out the businessday between these two days by excluding holidays and weekends.
Hi Experts, 

I want to find out the business day between two dates need to exclude holidays and weekends. Can anyone help me pls 
Hi Experts,

I am getting below error for the case comment. can anyone help me please. Error: SObject type CaseComment is not supported by this unit of work. 
below is the code. can anyone help me how to fix this issue.

 
public void registerNew(SObject record, Schema.sObjectField relatedToParentField, SObject relatedToParentRecord)
    {
        if(record.Id != null)
            throw new UnitOfWorkException('Only new records can be registered as new');
        String sObjectType = record.getSObjectType().getDescribe().getName();
        if(!m_newListByType.containsKey(sObjectType))
            throw new UnitOfWorkException(String.format('SObject type {0} is not supported by this unit of work', new String[] { sObjectType }));
        m_newListByType.get(sObjectType).add(record);
        if(relatedToParentRecord!=null && relatedToParentField!=null)
            registerRelationship(record, relatedToParentField, relatedToParentRecord);
    }

 
Hi Experts,

There is an email is comes from webservice, in that email we are searching for the policy number with that policy number we are creating case but problem here is that its  reading phone number also and creating case, so i observerd that phone number is coming prefix as "tel,T,telephone,phone,fax,F,+27" if i find anythig like this i need to ignore.
below is the expression we are using. can anyone help me please

public static final String REGEX_PATTERN_POLICY_NUMBER = '[0-9]{6,12}';
How can i redirect to the contact page , once the opportunity record get created. can anyone help me please.
 
/lightning/o/Opportunity/new?defaultFieldValues=Name={!Account.Name},ContactId={!Contact.Id}&backgroundContext=%2Flightning%2Fr%2FContact%2F{!Contact.Id}%2Fview

 
Hi Experts, 

I am not able to cover the code coverage for below else methods can anyone help me out, i have striked lines which i am not able to cover , till i can able to cover only 53% , please help me out.
public static void updateBeforeChange(List<SObject> newSobjs, Map<Id,SObject> oldSobjsMap)
    {
        List<Case> newCases = (List<Case>) newSobjs;
        Map<Id, Case> oldCasesMap = (Map<Id, Case>)oldSobjsMap;
        BusinessHours bh = [SELECT Id,SundayStartTime, MondayStartTime, TuesdayStartTime,WednesdayStartTime, ThursdayStartTime, FridayStartTime,SaturdayStartTime, SundayEndTime, MondayEndTime,TuesdayEndTime,WednesdayEndTime, ThursdayEndTime, FridayEndTime,SaturdayEndTime FROM BusinessHours WHERE IsDefault=true];//Quering the businesshours to user in IsWithin function
        system.debug('BusinessHoursBusinessHours  '+bh);
        for(Case cs : newCases)
        {
            Case oldCs = oldCasesMap.get(cs.Id);
            Boolean oldrecordtype= oldcs.RecordType_Name__c.equals('N_L_QNA');
            Boolean oldrecordtype1= oldcs.RecordType_Name__c.equals('L_QNA');
            Boolean newrecordtype = cs.RecordType_Name__c.equals('UW_L_QNA');
            Boolean newrecordtype1= cs.RecordType_Name__c.equals('N_L_QNA');
            string oldCsstatus = oldCasesMap.get(cs.Id).Status; 
            string dayOfWeek=cs.lastmodifieddate.format('EEEE');
            System.debug('Day : ' + dayOfWeek);
            DateTime dT = cs.LastModifiedDate;
            Date myDate = date.newinstance(dT.year(), dT.month(), dT.day());
            System.debug('myDate : ' + myDate );
            String Mon ='Monday';
            String Tue ='Tuesday';
            String Wed ='Wednesday';
            String Thur ='Thursday';
            String Fri ='Friday';
            String Sat= 'Saturday';
            String Sun= 'Sunday';
            
            
            Boolean isWithin = BusinessHours.isWithin(bh.id,  cs.LastModifiedDate);
            
            
            if((oldrecordtype  || oldrecordtype1 ) && (newrecordtype || newrecordtype1) )
            {
                if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
                {
                    
                   
                    cs.Sent_Hours__c= B_BusinessHours.getTimeDifferenceInMinutes(
                        cs.CreatedDate,
                        cs.LastModifiedDate,
                        businessHoursId);
                  
                    
                    Decimal mydecval = cs.Sent_Formula__c;
                    system.debug('mydecvalmydecvalmydecval'+mydecval);
                    Integer myintval = mydecval.intValue(); //Converting Decimal Value to Integer
                    system.debug('myintvalmyintvalmyintval'+myintval);
                    
                   
                    cs.Sent_to__c = B_BusinessHours.addMinutes(
                        myintval,
                        businessHoursId);
                }
                
                else if (dayOfWeek == Mon)
                {
                    cs.Sent_to__c= DateTime.newInstance(myDate,bh.MondayEndTime); 
                }
                else if(dayOfWeek == Tue)
                {
                    cs.Sent_to__c=  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;
                }
                else if(dayOfWeek == Wed)
                {
                    cs.Sent_to__c=  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;
                }
                else if(dayOfWeek == Thur)
                {
                    cs.Sent_to__c=  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;
                   
                }
                else if(dayOfWeek == Fri)
                {
                    cs.Sent_to__c=  DateTime.newInstance(myDate,bh.FridayEndTime) ;
                }
                else if(dayOfWeek == Sat)
                {
                    Date satdate = myDate- 1;
                    cs.Sent_to__c=  DateTime.newInstance(satdate,bh.FridayEndTime) ;
                }
                else if(dayOfWeek == Sun)
                {
                    Date Sundate=myDate- 2;
                    cs.Sent_to__c=  DateTime.newInstance(Sundate,bh.FridayEndTime) ;**
                }
                
                
            }
            
            
            
        }
        
    }
    
    public static Id businessHoursId
    {
        get
        {
            if (businessHoursId == null)
            {
                businessHoursId = B_BusinessHours.getBusinessHoursId();
            }
            return businessHoursId;
        }
        set;
    }
}
Below is my test class :
 
Public static testMethod void Case_Test_method1() 
{
  
  Id recordtyepe= Schema.SObjectType.Case.getRecordTypeInfosByName().get(' L - QNA').getRecordTypeId();
  Id recordtyepes= Schema.SObjectType.Case.getRecordTypeInfosByName().get('UW - L - QNA').getRecordTypeId();

  BusinessHours bhs=[SELECT Id,SundayStartTime, MondayStartTime, TuesdayStartTime,WednesdayStartTime, ThursdayStartTime, FridayStartTime,SaturdayStartTime, SundayEndTime, MondayEndTime,TuesdayEndTime,WednesdayEndTime, ThursdayEndTime, FridayEndTime,SaturdayEndTime FROM BusinessHours WHERE IsDefault=true];
  Boolean isWithin = BusinessHours.isWithin(bhs.id, datetime.newInstance(2020, 03, 09, 05, 30, 0));
  //System.assert(bhs.size()==1);
 if(isWithin==false)
 {
  case c1 = new case();
  c1.Origin='email';
  c1.Status='Assigned';
  c1.RecordtypeId= recordtyepe;
  c1.Process__c='Verify';
  c1.Process__c= 'Preparation';
  insert c1;
  
 //long hours = B_BusinessHours.getTimeDifferenceInMinutes(c1.createddate,c1.lastmodifieddate,bhs.id);

  //c1.Sent_to_Prepare_Quote_Hours__c=hours;
  c1.Status='Quote Completed and Emailed to Broker';
  c1.Process__c='Quote Preparation';
  c1.Process__c='Classify/Verify';
  c1.RecordtypeId =recordtyepes;
  c1.Sent_to__c= system.now();
  try{
  update c1;
  }
  catch(exception e){}
 }
 }
    }


 
Hi Experts,

I am not Not able to cover the below class handler which works before update , can anyone help me out. please. still its only 53%, majority of the issue is wiht else part which i bolded.
 
public without sharing class Stamp_Case
{
    
    public static void updateBeforeChange(List<SObject> newSobjs, Map<Id,SObject> oldSobjsMap)
    {
        List<Case> newCases = (List<Case>) newSobjs;
        Map<Id, Case> oldCasesMap = (Map<Id, Case>)oldSobjsMap;
        BusinessHours bh = [SELECT Id,SundayStartTime, MondayStartTime, TuesdayStartTime,WednesdayStartTime, ThursdayStartTime, FridayStartTime,SaturdayStartTime, SundayEndTime, MondayEndTime,TuesdayEndTime,WednesdayEndTime, ThursdayEndTime, FridayEndTime,SaturdayEndTime FROM BusinessHours WHERE IsDefault=true];//Quering the businesshours to user in IsWithin function
        system.debug('BusinessHoursBusinessHours  '+bh);
        for(Case cs : newCases)
        {
            Case oldCs = oldCasesMap.get(cs.Id);
            Boolean oldrecordtype= oldcs.RecordType_Name__c.equals('N_L_QNA');
            Boolean oldrecordtype1= oldcs.RecordType_Name__c.equals('L_QNA');
            Boolean newrecordtype = cs.RecordType_Name__c.equals('UW_L_QNA');
            Boolean newrecordtype1= cs.RecordType_Name__c.equals('N_L_QNA');
            string oldCsstatus = oldCasesMap.get(cs.Id).Status; 
            string dayOfWeek=cs.lastmodifieddate.format('EEEE');
            System.debug('Day : ' + dayOfWeek);
            DateTime dT = cs.LastModifiedDate;
            Date myDate = date.newinstance(dT.year(), dT.month(), dT.day());
            System.debug('myDate : ' + myDate );
            String Mon ='Monday';
            String Tue ='Tuesday';
            String Wed ='Wednesday';
            String Thur ='Thursday';
            String Fri ='Friday';
            String Sat= 'Saturday';
            String Sun= 'Sunday';
            
            
            Boolean isWithin = BusinessHours.isWithin(bh.id,  cs.LastModifiedDate);
            
            
            if((oldrecordtype  || oldrecordtype1 ) && (newrecordtype || newrecordtype1) )
            {
                if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
                {
                    
                   
                    cs.Sent_Hours__c= B_BusinessHours.getTimeDifferenceInMinutes(
                        cs.CreatedDate,
                        cs.LastModifiedDate,
                        businessHoursId);
                  
                    
                    Decimal mydecval = cs.Sent_Formula__c;
                    system.debug('mydecvalmydecvalmydecval'+mydecval);
                    Integer myintval = mydecval.intValue(); //Converting Decimal Value to Integer
                    system.debug('myintvalmyintvalmyintval'+myintval);
                    
                   
                    cs.Sent_to__c = B_BusinessHours.addMinutes(
                        myintval,
                        businessHoursId);
                }
                
                **else if (dayOfWeek == Mon)
                {
                    cs.Sent_to__c= DateTime.newInstance(myDate,bh.MondayEndTime); 
                }
                else if(dayOfWeek == Tue)
                {
                    cs.Sent_to__c=  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;
                }
                else if(dayOfWeek == Wed)
                {
                    cs.Sent_to__c=  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;
                }
                else if(dayOfWeek == Thur)
                {
                    cs.Sent_to__c=  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;
                   
                }
                else if(dayOfWeek == Fri)
                {
                    cs.Sent_to__c=  DateTime.newInstance(myDate,bh.FridayEndTime) ;
                }
                else if(dayOfWeek == Sat)
                {
                    Date satdate = myDate- 1;
                    cs.Sent_to__c=  DateTime.newInstance(satdate,bh.FridayEndTime) ;
                }
                else if(dayOfWeek == Sun)
                {
                    Date Sundate=myDate- 2;
                    cs.Sent_to__c=  DateTime.newInstance(Sundate,bh.FridayEndTime) ;**
                }
                
                
            }
            
            if((cs.status =='Emailed to Broker' || cs.status==' Emailed to Distribution') && oldCsstatus != cs.status)
            {
                **if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
                {
                    cs.Dist_Hours__c = B_BusinessHours.getTimeDifferenceInMinutes(
                        cs.CreatedDate,
                        cs.LastModifiedDate,
                        businessHoursId);
                    
                    Decimal mydecval = cs.Dist_Formula__c;
                   
                    Integer myintval = mydecval.intValue();
                    system.debug('myintvalmyintvalmyintval'+myintval);
                    cs.Dist__c= B_BusinessHours.addMinutes(
                        myintval,
                        businessHoursId);
                }
                else if (dayOfWeek == Mon)
                {
                    cs.Dist__c= DateTime.newInstance(myDate,bh.MondayEndTime); 
                }
                else if(dayOfWeek == Tue)
                {
                    cs.Dist__c=  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;
                }
                else if(dayOfWeek == Wed)
                {
                    cs.Dist__c=  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;
                }
                else if(dayOfWeek == Thur)
                {
                    cs.Dist__c=  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;
                  
                }
                else if(dayOfWeek == Fri)
                {
                    cs.Dist__c=  DateTime.newInstance(myDate,bh.FridayEndTime) ;
                }
                else if(dayOfWeek == Sat)
                {
                    Date satdate = myDate- 1;
                    cs.Dist__c=  DateTime.newInstance(satdate,bh.FridayEndTime) ;
                }
                else if(dayOfWeek == Sun)
                {
                    Date Sundate=myDate- 2;
                    cs.Dist__c=  DateTime.newInstance(Sundate,bh.FridayEndTime) ;
                }**
                
            }
            
            if(cs.Process__c=='Verify' && cs.Verify_Date__c== null)
            {
                
                if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
                { 
                    
                    cs.Date_Hours__c= B_BusinessHours.getTimeDifferenceInMinutes(
                        cs.CreatedDate,
                        cs.LastModifiedDate,
                        businessHoursId);
                    
                    Decimal mydecval = cs.Date_Formula__c;
                  
                    Integer myintval = mydecval.intValue();
                   
                    cs.Verify_Date__c= B_BusinessHours.addMinutes(
                        myintval,
                        businessHoursId);
                }
                
                **else if (dayOfWeek == Mon)
                {
                    cs.Verify_Date__c = DateTime.newInstance(myDate,bh.MondayEndTime); 
                }
                else if(dayOfWeek == Tue)
                {
                    cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;
                }
                else if(dayOfWeek == Wed)
                {
                    cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;
                }
                else if(dayOfWeek == Thur)
                {
                    cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;
                   
                }
                else if(dayOfWeek == Fri)
                {
                    cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.FridayEndTime) ;
                }
                else if(dayOfWeek == Sat)
                {
                    Date satdate = myDate- 1;
                    cs.Verify_Date__c =  DateTime.newInstance(satdate,bh.FridayEndTime) ;
                }
                else if(dayOfWeek == Sun)
                {
                    Date Sundate=myDate- 2;
                    cs.Verify_Date__c =  DateTime.newInstance(Sundate,bh.FridayEndTime) ;**
                } 
                
            }
            
            if(cs.Process__c=='Preparation' && cs.Preparation_Date__c== null)
            {
                
                if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
              {
                
                cs.Preparation_Date_Hours__c= B_BusinessHours.getTimeDifferenceInMinutes(
                    cs.CreatedDate,
                    cs.LastModifiedDate,
                    businessHoursId);
                
                Decimal mydecval = cs.Preparation_Date_Formula__c;
                
                Integer myintval = mydecval.intValue();
                
                cs.Preparation_Date__c = B_BusinessHours.addMinutes(
                    myintval,
                    businessHoursId);
                
            }
            
            else if (dayOfWeek == Mon)
            {
                **cs.Preparation_Date__c = DateTime.newInstance(myDate,bh.MondayEndTime);** 
            }
            else if(dayOfWeek == Tue)
            {
                **cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;**
            }
            else if(dayOfWeek == Wed)
            {
                **cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;**
            }
            else if(dayOfWeek == Thur)
            {
                cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;
               
            }
            **else if(dayOfWeek == Fri)
            {
                cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.FridayEndTime) ;
            }
            else if(dayOfWeek == Sat)
            {
                Date satdate = myDate- 1;
                cs.Preparation_Date__c =  DateTime.newInstance(satdate,bh.FridayEndTime) ;
            }
            else if(dayOfWeek == Sun)
            {
                Date Sundate=myDate- 2;
                cs.Preparation_Date__c =  DateTime.newInstance(Sundate,bh.FridayEndTime) ;**
            } 
            
          }
            
        }
        
    }
    
    public static Id businessHoursId
    {
        get
        {
            if (businessHoursId == null)
            {
                businessHoursId = B_BusinessHours.getBusinessHoursId();
            }
            return businessHoursId;
        }
        set;
    }
}


Below is my Test class.

        @isTest
    public class Case_Test{
    
    Public static testMethod void Test_method() 
    {
    
      Id recordtyepe= Schema.SObjectType.Case.getRecordTypeInfosByName().get('- L - QNA').getRecordTypeId();
      Id recordtyepes= Schema.SObjectType.Case.getRecordTypeInfosByName().get('UW - L - QNA').getRecordTypeId();
      List<BusinessHours> bhs=[select id from BusinessHours where IsDefault=true];
     
      case c = new case();
      c.Origin='email';
      c.Status='Assigned';
      c.RecordtypeId= recordtyepe;
      c.Process__c='Verify';
      c.Process__c= 'Preparation';
      insert c;
      c.Process__c='Preparation';
      c.Process__c='Verify';
      c.RecordtypeId =recordtyepes;
      Test.setCreatedDate(c.Id,  datetime.newInstance(2019, 11, 11, 11, 30, 0));
       Test.startTest();
       case cs= [SELECT Id, CreatedDate,LastModifiedDate FROM case  where origin='email' limit 1];
       System.assertEquals(cs.CreatedDate,  DateTime.newInstance(2019,11,11,11,30,0));
       Test.stopTest();
       update c;
     
    }
    }

 
Hi Experts,

I have requirment i need create a button(not java script button because i cant use in lighting) when i click on that button new record page has to open and also i want set a default value in that new record page, can anyone hlep me please.
Hi Experts,

I am trying to update the State and Country ISO Code picklist values using packages but i am getting below error while deploying using workbench. can anyone tell me how to update it please

here is the package:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Address</members>
        <name>Settings</name>
    </types>
    <version>42.0</version>
</Package>

Error:
Invalid iso code AB for country Aruba
Hi Experts,

Can anyone help me how to write test class for the below method.

public override void onCommit(){
        
        OM_ManageService manageRemittanceSVC = (OM_ManageRService)this.svc;
        String accJSON = OM_WorkService.getJSONAttribute(manageRemittanceSVC.jsonString, 'AccountInfo');
        Map<String, List<SObject>> accObjects =  OM_WorkService.getSObjects(accJSON);
        Account acc = (Account)accObjects.get('Account')[0];
        
        if(acc!= null){
            upsert acc;
            super.onCommit();
            
            }
            
        Below is the OM_WorkService.getJSONAttribut    
             
             public static String getJSONAttribute(String jsonStr, String attr){
        Map<String, Object> m = (Map<String, Object>)JSON.deserializeUntyped(jsonStr);
        if(m.containsKey(attr))
            return (String)m.get(attr);
        
        return null;
    }
 
Hi Experts,

Can anyone help me how out, how to the stop the triggers not to fire any profile using custom setting. Thanks in advance
Hi Experts,

We have requirment where we need to replace Opportunity Proudct with the standard object oportunity product object, so i have edited entire controller code
but problem here is that when i replace stadnardcontroller with the OpportunityLineItem in the visualforce page its not allowing me to work its throwing an error called "Error: List controllers are not supported for OpportunityLineItem    ", 
can anyone help me out, how to fix this issue. 
 
Vf page: 
<apex:page standardController="Product__c" recordSetVar="oppProds" extensions="ProductController" showHeader="false" standardStylesheets="true" sidebar="false"
  docType="html-5.0">
   
    <body>
        <apex:form id="frm">
            <div align="center">
                <div class="h1Div" >
                    <input type="button" id="btnBack1" value="Back" class="sf1buttonSFBlue backButtonControlClass" onClick="javascript: goBack();" style="float: left;margin-top: -5px;margin-right: 15px;height: 35px;"/>
                    <h1>Opportunity Products</h1>
                    <img src="{!$Resource.SF1HeaderLogoSmall}" style="float:right;width: 100px;"/>
                </div>
                <br/>
                <apex:pageMessages id="MESSAGES"/>
            </div>
            
            <div class="sf1divBlock">
                <div class="sf1headerLabel">
                    <apex:outputLabel value="{!cOpp.Name}" style="margin-left: 5px;"/>
                </div>
                <br/>
                <apex:outputPanel id="OPPPRODPANEL">
                    <table id="OPPPRODTABLE" class="sf1Table" style="width:100%;">
                        <thead>
                            <tr>
                                <th width="50%"> Product </th>
                                <th width="12%"> Include in next quote </th>
                                <th width="22.5%"> Quantity </th>
                                <th width="22.5%"> Requested Price </th>
                                <th class="DMLActions" width="5%"> Action </th>
                            </tr>
                        </thead> 
                        <tbody>
                            <apex:variable var="rowClass" value="odd"/>
                            <apex:variable var="rowNum" value="{!0}"/> 
                            <apex:repeat value="{!clstOppProds}" var="oppProd">
                                <tr class="{!rowClass}">
                                    <td>
                                        <div class="scrollable-dropdown-menu">
                                            <input type="text" id="prodName{!rowNum}" name="prodName{!rowNum}" class="sf1Input"/>
                                        </div>
                                        <script>
                                            //Initialize the type ahead
                                            var prodName{!rowNum} = jQuery('#prodName{!rowNum}');
                                            if(prodName{!rowNum}){
                                                prodName{!rowNum}.typeahead(
                                                    {
                                                        minLength: 3,
                                                        highlight: true
                                                    },
                                                    {
                                                        limit: 999,
                                                        display: 'value',
                                                        source: function(searchText, syncCallback, asyncCallback) {
                                                            searchText = searchText.split('\\').join('\\\\');
                                                            searchText = searchText.split('\'').join('\\\'');
                                                            var sObj = new SObjectModel.Product2();
                                                            sObj.retrieve({ 
                                                                where:{
                                                                    or:{
                                                                        Name: {like: searchText + '%'},
                                                                        or:{
                                                                            Description: {like: searchText + '%'},
                                                                            Product2: {like : searchText + '%'}
                                                                        }
                                                                    },
                                                                    and:{
                                                                        Active__c: {eq: true},
                                                                        or:{
                                                                            RecordTypeId: {eq: '{!ProductRTId}'},
                                                                            and:{
                                                                                Status__c: {eq: 'Approved'},
                                                                                Product__c: {eq: ''}
                                                                            }
                                                                        }
                                                                    }
                                                                },
                                                                orderby: [{Name: 'ASC'}],
                                                                limit:999},
                                                                function(err,records){
                                                                    if(err){
                                                                        alert(err);
                                                                    } else {
                                                                        var dataList = [];
                                                                        var maxLength = 1;
                                                                        jQuery.each(records, function(index, record){
                                                                            dataList.push({
                                                                                id: record.get('Id'),
                                                                                value: jQuery('<div/>').html(record.get('Name')).text(),
                                                                                code: jQuery('<div/>').html(record.get('Type_Code__c')).text(),
                                                                                desc2: jQuery('<div/>').html(record.get('Description')).text()
                                                                            });
                                                                        });
                                                                        asyncCallback(dataList);
                                                                    }
                                                                }
                                                            ) 
                                                        },
                                                        templates: {
                                                            suggestion: function (data) {
                                                                var desc = data.value;
                                                                if(data.desc2) desc += ' - ' + data.desc2;
                                                                return '<div><table class="tt-table"><tr><td class="tt-table-td1">' + desc + '</td><td class="tt-table-td2">' + data.code + '</td></tr></table></div>';
                                                            }
                                                        }
                                                    }
                                                ).on('typeahead:selected', function (object, datum) {
                                                    setProd({!rowNum},datum.id,datum.value);
                                                }).on('typeahead:autocompleted', function (object, datum) {
                                                    setProd({!rowNum},datum.id,datum.value);
                                                }).on('typeahead:change', function (event, data) {
                                                    //Reset the fields to blank
                                                    
                                                });
                                            }
                                            prodName{!rowNum}.typeahead('val', '{!JSENCODE(oppProd.Product__r.Name)}');
                                        </script>
                                    </td>
                                    
                                    <td>
                                        <apex:inputField value="{!oppProd.Next_Quote__c}" style="width:30px; height:20px;"/>
                                    </td>
                                    <td>
                                        <apex:inputField value="{!oppProd.Quantity__c}" styleClass="sf1Input"/>
                                    </td>
                                    <td>
                                        <apex:inputField value="{!oppProd.Price__c}" styleClass="sf1Input"/>
                                    </td>
                                    <td valign="top" class="DMLActions">
                                        <input type="button" id="btnDelete{!oppProd.id}" class="sf1buttonDelete" value="" onClick="removeRow('{!rowNum}');" />
                                    </td>
                                </tr>
                                <apex:variable var="rowClass" value="{!IF(rowClass == 'odd','','odd')}"/> 
                                <apex:variable var="rowNum" value="{!rowNum + 1}"/> 
                            </apex:repeat>
                        </tbody>
                    </table>
                </apex:outputPanel>
                <table class="sf1InputTableTwoCol">
                    <tr>
                        <td>
                            <input type="button" id="btnBack" class="sf1buttonSFBlue" value="Back" onClick="goBack();" />
                            <input type="button" id="btnAddNew" class="sf1buttonSFBlue" value="Add New" onClick="addNew();" />
                            <input type="button" id="btnSave" class="sf1buttonSFBlue" value="Save" onClick="doSave();" />
                        </td>
                    </tr>
                </table>
            </div>
            
            <apex:actionFunction name="setProd" action="{!setProd}" reRender="MESSAGES" status="status">
                <apex:param name="p1" value="" assignTo="{!selectedRowNum}"/>
                <apex:param name="p2" value="" assignTo="{!selectedRowProdId}"/>
                <apex:param name="p3" value="" assignTo="{!selectedRowProdName}"/>
            </apex:actionFunction>
            <apex:actionFunction name="removeRow" action="{!removeRow}" reRender="MESSAGES,OPPPRODPANEL" status="status">
                <apex:param name="p1" value="" assignTo="{!selectedRowNum}"/>
            </apex:actionFunction>
            <apex:actionFunction name="goBack" action="{!cancel}" reRender="MESSAGES" status="status"/>
            <apex:actionFunction name="doSave" action="{!doSave}" reRender="MESSAGES" status="status"/>
            <apex:actionFunction name="addNew" action="{!addNew}" reRender="MESSAGES,OPPPRODPANEL" status="status"/>
            
            <apex:actionstatus id="status">
                <apex:facet name="start">
                    <div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb;height: 100%;opacity:0.65;width:100%;">
                        <div class="waitingHolder" style="top:220px;">
                            <img class="waitingImage" src="{!$Resource.Salesfroce1Loading}" title="Processing..." />
                        </div>
                    </div>
                </apex:facet> 
            </apex:actionstatus>
        </apex:form>
    </body>
</apex:page>


Apex class:

public class ProductController {
    public Opportunity cOpp {get;set;}
    public Integer selectedRowNum {get;set;}
    public String selectedRowProdId {get;set;}
    public String selectedRowProdName {get;set;}
    public List<OpportunityLineItem> clstOppProds {get;set;}
    public List<OpportunityLineItem> clstDelOppProds {get;set;}
    public String getJDEProductRTId(){
        return [SELECT Id FROM RecordType WHERE SObjectType = 'Product2' AND Name = 'New Products' LIMIT 1].get(0).Id;
    }
	
	   public ProductController(ApexPages.StandardSetController ssc) {
        selectedRowNum = null;
        selectedRowProdId = null;
        selectedRowProdName = null;
        String oppId = ApexPages.currentPage().getParameters().get('id');
        cOpp = null;
        for(Opportunity o : [SELECT Id,Name FROM Opportunity WHERE Id = :oppId]) cOpp = o;
        clstOppProds = new List<OpportunityLineItem>();
        clstDelOppProds = new List<OpportunityLineItem>();
        if(oppId != null) clstOppProds = [SELECT Id,Opportunityid,Next_Quote__c,Product2id,Product2.Name,Quantity__c,Price__c FROM OpportunityLineItem WHERE Opportunityid = :oppId];
    }
	
	 public PageReference setProd(){
         PageReference pg = null;
         OpportunityLineItem op = clstOppProds.get(selectedRowNum);
         Product2 pt = new Product2(id=selectedRowProdId,name=selectedRowProdName);
         op.Product2id = selectedRowProdId;
         op.Product2.Name = pt.Name;
         return pg;
     }
	 
	 public PageReference removeRow(){
         PageReference pg = null;
         OpportunityLineItem op = clstOppProds.remove(selectedRowNum);
         if(op.Id != null) clstDelOppProds.add(op);
         return pg;
     }
	 
	   public PageReference addNew(){
         PageReference pg = null;
         clstOppProds.add(new OpportunityLineItem(Opportunityid=cOpp.Id));
         return pg;
     }
	 public PageReference doSave(){
         PageReference pg = null;
         SavePoint sp = Database.setSavePoint();
         try{
             delete clstDelOppProds;
             upsert clstOppProds;
             pg = new PageReference('/'+cOpp.Id);
         }catch(Exception e){
             Database.rollback(sp);
             Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, e.getMessage()));
         }
         return pg;
     }
}

 
Hi Experts,

I have small requirement where i need to filter a long text area field called Desc__c which i am not able to do that can anyone help me please.

OrderItem oli1 = new OrderItem ();
        oli1.Orderid = order.Id;
        oli1.Desc__c= 'Test OLI 1'; 
      insert oli1;


 OrderItem oli2 = [SELECT Id, Orderid
                    FROM OrderItem WHERE  Desc__c = 'Test OLI 1' LIMIT 1];

In this filter condition its throwing an error can anyone help me please thanks in adavance
Hi Experts,

Can anyone helps me , while running my test class i am getting below error. Below is my code anyone help  me please. the area which i made bold in the insert command i receiving this can anyone helps me please.

DUPLICATE_VALUE, This price definition already exists in this price book: []   


Account a = new Account(Name='testAccount',RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Customer').getRecordTypeId()); //Added by Purnima for Story S-562343
         insert a; 
        
        Id pricebookId = Test.getStandardPricebookId();
        
        Product2 prod = new Product2(Name = 'Laptop X200', 
                                     Family = 'Hardware');
        insert prod;
        
     
        
        /*PricebookEntry standardPrice = new PricebookEntry(
            Pricebook2Id = pricebookId, Product2Id = prod.Id,
            UnitPrice = 10000, IsActive = true);
        insert standardPrice;*/
        
        PriceBookEntry stdPriceBookEntry = new PriceBookEntry();
        stdPriceBookEntry.Product2Id=prod.Id;
        stdPriceBookEntry.Pricebook2Id=pricebookId;
        stdPriceBookEntry.UnitPrice=2000;
        stdPriceBookEntry.IsActive=true;
        insert stdPriceBookEntry;

        
        Pricebook2 customPB = new Pricebook2(Name='Custom Pricebook', isActive=true);
        insert customPB;
        
        PricebookEntry customPrice = new PricebookEntry(
            Pricebook2Id = customPB.Id, Product2Id = prod.Id,
            UnitPrice = 12000, IsActive = true);
        insert customPrice;
         Product_Type__c productType = new Product_Type__c();        
        productType.Product_Type_Code__c = 'End';
      
        insert productType;
        
        
        Opportunity opp = new Opportunity(Name='Test', 
                                          Account = a, 
                                         // Product__c='GRI Retail',
                                          NextStep='test',
                                          PriceBook2 = customPB,
                                          CloseDate = System.today(),
                                          AccountId=a.Id, 
                                         // Opportunity_Name__c='testOpp',
                                         // Product_Family__c='Retail',
                                        Industry__c='Other',
                                        Description='TestTestTest',
                                          StageName='Closed Won - One Time' 
                                          );
       
       insert opp; 
        
    
     
    List<Opportunity_Product__c> oppProdList = new List<Opportunity_Product__c>();
     for(Integer i=1;i<=10;i++)
     oppProdList.add(new Opportunity_Product__c (Opportunity__c = opp.Id,Product__c = productType.id));
     
     System.debug('test@@@'+ oppProdList );
        
        insert oppProdList;
        
        

     
     
     ApexPages.StandardSetController sc = new ApexPages.StandardSetController(oppProdList);
    
     
    
      PageReference pageRef = Page.OpportunityProducts;
        pageRef.getParameters().put('id', String.valueOf(''));
        Test.setCurrentPage(pageRef);
    
    
    //Test.setCurrentPageReference(Page.OpportunityProducts);
    
    OpportunityController obj= new OpportunityController(sc);
    obj.selectedRowNum=1;
    obj.selectedRowProdId=productType.id;
    obj.selectedRowProdName=productType.Name;
    obj.cOpp=opp;
    List<Opportunity_Product__c> testopp= new List<Opportunity_Product__c>();
    obj.clstOppProds=oppProdList;
    List<Opportunity_Product__c> testOpps= new  List<Opportunity_Product__c>();
    obj.clstDelOppProds=oppProdList;
    
    obj.getJDEProductRTId();
   
    //Product_Type__c pt = new Product_Type__c(id='test', name='test');
    System.debug('clstOppProds==>' + obj.clstOppProds);
        System.debug('clstDelOppProds==>' + obj.clstDelOppProds);
    
    PageReference pg = obj.doSave(); 
    PageReference pg1 = obj.addNew(); 
    //PageReference pg3 = obj.setProd();
    PageReference pg2 = obj.removeRow(); 
    
 
Hi Experts,
I wrote one batch class with contractor like below. but when i was try to run my test class i am getting an error that constructor is not defind. below is my test class as well , can anyone help me plesae . thanks in advance
private  list<String> sOrganization;
public UpdateAccountCallList(String[] sorg) {
sOrganization = sorg;
}
 
 
Test class:
 
@isTest
public class AccountUpdatecallistBatchJobTest
{
static testMethod void testMethod1()
{
List<Account> lstAccount= new List<Account>();
List<Account> lstAccount1= new List<Account>();
List<Account> lstAccount2= new List<Account>();
List<Account> lstAccount3= new List<Account>();
List<Account> lstAccount4= new List<Account>();
List<Account> lstAccount5= new List<Account>();
for(Integer i=0 ;i <5;i++)
{
Account acc = new Account();
acc.Name =’Name’+i;
acc.Call_List_Frequency__c=8;
acc.Call_List__c=true;
acc.Call_List_Start_Date__c=system.today()-1;
acc.Call_List_Preferred_Day__c=’MOnday’;
date myDate = date.today();
acc.Call_List_Next_Preferred_Date__c=myDate.toStartofWeek()+0;
Account acc1 = new Account();
acc1.Name =’Name1’+i;
acc1.Call_List_Frequency__c=6.0;
acc1.Call_List__c=true;
acc1.Call_List_Start_Date__c=system.today()-1;
acc1.Call_List_Preferred_Day__c=’Tuesday’;
date myDate1 = date.today();
acc1.Call_List_Next_Preferred_Date__c=myDate1.toStartofWeek()+1;
lstAccount1.add(acc1);
Account acc2 = new Account();
acc2.Name =’Name1’+i;
acc2.Call_List_Frequency__c=6.0;
acc2.Call_List__c=true;
acc2.Call_List_Start_Date__c=system.today()+1;
acc2.Call_List_Preferred_Day__c=’Wednesday’;
date myDate2 = date.today();
acc2.Call_List_Next_Preferred_Date__c=myDate2.toStartofWeek()+2;
lstAccount2.add(acc2);
Account acc3 = new Account();
acc3.Name =’Name1’+i;
acc3.Call_List_Frequency__c=6.0;
acc3.Call_List__c=true;
acc3.Call_List_Start_Date__c=system.today()-1;
acc3.Call_List_Preferred_Day__c=’Thursday’;
date myDate3 = date.today();
acc3.Call_List_Next_Preferred_Date__c=myDate3.toStartofWeek()+3;
lstAccount3.add(acc3);
Account acc4 = new Account();
acc4.Name =’Name1’+i;
acc4.Call_List_Frequency__c=6.0;
acc4.Call_List__c=true;
acc4.Call_List_Start_Date__c=system.today()-1;
acc4.Call_List_Preferred_Day__c=’Friday’;
date myDate4 = date.today();
acc4.Call_List_Next_Preferred_Date__c=myDate4.toStartofWeek()+4;
lstAccount4.add(acc4);
Account acc5 = new Account();
acc5.Name =’Name1’+i;
acc5.Call_List_Frequency__c=6.0;
acc5.Call_List__c=true;
acc5.Call_List_Start_Date__c=system.today()-1;
acc5.Call_List_Preferred_Day__c=’None’;
acc5.Call_List_Next_Preferred_Date__c=system.today();
lstAccount5.add(acc5);
}
insert lstAccount;
insert lstAccount1;
insert lstAccount2;
insert lstAccount3;
insert lstAccount4;
insert lstAccount5;
Test.startTest();
UpdateAccountCallList obj = new UpdateAccountCallList();
obj.currentweek=9;
DataBase.executeBatch(obj);
Test.stopTest();
}
}
Hi Experts,

I have requirement i need to update the task owner once lead owner changes for me its working but getting too many soql errors when i chek debug log i am getting lot of records including my record , can anyone help me please, my trigger is after insert and after update which is on lead object.

 Map<Id, Lead> leadMap = new Map<Id, Lead>([Select Id, OwnerID from Lead where Id IN: Oldmap.keyset()]);
         system.debug('++++owners'+leadMap );
         
         
          for(Task tsk:[select id,OwnerID,Whoid from task where whoid in :leadMap.keyset()])
          {
           system.debug('++++tsk'+tsk); 
           Id owner=leadMap.get(tsk.whoid).ownerid;
           system.debug('++++owner'+owner);
           id test=leadMap.get(tsk.whoId).id;
            system.debug('++++test'+test);
            if(!leadMap.containskey(tsk.ownerid) &&  tsk.whoid !=null && leadMap.containskey(tsk.whoId) && !string.valueOf(owner).startsWith('00G') && leadMap.get(tsk.whoId).id==tsk.whoid )
            {
              tsk.ownerid=leadMap.get(tsk.whoid).ownerid;
              system.debug('++++owners'+tsk.ownerid);
              oldtasks.add(tsk);
              system.debug('++++tasks'+oldtasks);
            }
            }
            update oldtasks;
            system.debug('++++'+oldtasks); 

 
HI Experts,

I am new to Lighting , i have requirment i need to update Account fields by creating button ,  i have created component and helper and controller its working fine when i pass id in my controller but i need to make my code dyanmic means what ever account record i pick randomly that account field has to update. can anyone help me pls below is my code. Thanks in advace

Component :

<aura:component controller="AccountFieldupdats" implements="force:lightningQuickActionWithoutHeader,flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName">
    <!--<aura:attribute name="updateCheckBox" type="Account" default="{'sobjectType':'Account'}"/>-->
    <lightning:button variant="brand" label="Update A Checkbox" onclick="{!c.updateCheck11}"  />
</aura:component>

Controller :

({
    updateCheck11  : function(component, event, helper) {
        alert('inside controller');
        helper.updateCheck11_helper(component, event, helper);
    }
})

Helper :
({
    updateCheck11_helper  : function(component, event, helper) {
        alert('inside helper');
        var save_action = component.get("c.updateCheck");
        save_action.setParams({ });
        $A.enqueueAction(save_action);


        
    }
})

Apex controller:

public class AccountFieldupdats {
 @AuraEnabled
public static void updateCheck(){
list<Account> Act_list = new list<Account>();
    Act_list = [select id,Call_List__c from Account where id=''];
     Account ACC =new Account();
     ACC.id=Act_list[0].id;
     ACC.Call_List__c=False;
    update ACC;

}
}
Hi Experts,

Below is my code and i am new lighting , i have created a custom visualforce button its working fine in classic but its not working in lighting and also after clicking on that button its showing some black page , it has show to the same record page, can anyone help me pls. below is my code.
and my button behaviour is "BehaviorDisplay in existing window without sidebar or header"

<apex:page standardController="Account">
        <apex:includeScript value="../../soap/ajax/23.0/connection.js"/>
    <script>
    sforce.connection.sessionId='{!GETSESSIONID()}';
    var url = parent.location.href; 
    var updateRecords = []; 
    var update_account = new sforce.SObject("Account"); 
    update_account.id = "{!Account.Id}"; 
 update_account.List__c = "False";
updateRecords.push(update_account); 
 
       result = sforce.connection.update(updateRecords); 
       if (result[0].success=="true"){ 
       if(typeof sforce !== 'undefined') {
       sforce.one.back(true);
        
        } else {
window.location.href = document.referrer;
}
 }
        else
        alert("Failed to Update ");
        </script>
        </apex:page>
Hi Experts,

I have below code which is calling before update on account ,i have nested loops because of that i am getting cpu time out issue, can anyone convert my code into MAp please.

        Set<Id> Accids= New Set<Id>();
        Set<String>Fun= new set<string>();
        
        Id AccRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('RecordType').getRecordTypeId();
        
        
        if(AccRecordTypeId !=null)
        {
        FOR(Account A : newList)
        { 
            
            if(A.RecordTypeId == AccRecordTypeId)
            {
                Accids.Add(A.id);
                system.debug('%%%%%%'+Accids);
            }    
            
        }
        
       } 
        String samp = System.Label.User_ID; 
        List<Function__c> PR = [Select Id,Salesforce_ID__c,Function_Def__c,Person__c,Pernr__c from Function__c where Salesforce_ID__c IN : Accids and Pernr__c !=null ];
        system.debug('$$$$$$'+PR );
        
        for(Function__c pf: PR)
        {
            if( pf.Salesforce_ID__c != Null)
            {
                system.debug('^^^^^^'+pf);
                Fun.add(pf.Pernr__c);
                system.debug('#######'+Fun);
            }
        }
        
        list<Person__c> gp = [ select id , Employee_ID__c,User__c,OwnerId from Person__c where Employee_ID__c in : Fun];
        system.debug('@@@@@'+gp );
        
        if(gp.size()>0)
        {
            
            FOR(Account A : newList)
                
            {
                
                for(Person__c gpr: gp)
                {
                    for( Function__c pfr: PR)
                    {
                        if(gpr.User__c!=null && pfr.Function_Def__c!=null )
                        {
                            
                            if(pfr.Function_Def__c== 'ABC' )
                            {
                                
                                system.debug('&&&&&'+gpr);
                                A.OwnerId=gpr.User__c;
                                system.debug('!!!!!'+A.ownerid);
                                
                            }
                            else if(pfr.Function_Def__c== 'DEF' || pfr.Function_Def__c== 'GHI' || pfr.Function_Def__c== 'JKL')
                            {
                                A.OwnerId=gpr.User__c;
                                system.debug('88888'+A.ownerid);
                                
                            }
                        }
                        else 
                        {
                            A.OwnerId=samp;
                            system.debug('***'+A.ownerid);
                        }
                    }
                }
            }
            
        }
Hi Experts,

Can anyone help me how to write test class for the below method.

public override void onCommit(){
        
        OM_ManageService manageRemittanceSVC = (OM_ManageRService)this.svc;
        String accJSON = OM_WorkService.getJSONAttribute(manageRemittanceSVC.jsonString, 'AccountInfo');
        Map<String, List<SObject>> accObjects =  OM_WorkService.getSObjects(accJSON);
        Account acc = (Account)accObjects.get('Account')[0];
        
        if(acc!= null){
            upsert acc;
            super.onCommit();
            
            }
            
        Below is the OM_WorkService.getJSONAttribut    
             
             public static String getJSONAttribute(String jsonStr, String attr){
        Map<String, Object> m = (Map<String, Object>)JSON.deserializeUntyped(jsonStr);
        if(m.containsKey(attr))
            return (String)m.get(attr);
        
        return null;
    }
 
HI Experts,

I Have requirment ,where i need to find out the businessday between two days, eg: if startdate is today, and startday-3, i need to find out the businessday between these two days by excluding holidays and weekends.
Hi Experts, 

I want to find out the business day between two dates need to exclude holidays and weekends. Can anyone help me pls 
Hi Experts,

I am getting below error for the case comment. can anyone help me please. Error: SObject type CaseComment is not supported by this unit of work. 
below is the code. can anyone help me how to fix this issue.

 
public void registerNew(SObject record, Schema.sObjectField relatedToParentField, SObject relatedToParentRecord)
    {
        if(record.Id != null)
            throw new UnitOfWorkException('Only new records can be registered as new');
        String sObjectType = record.getSObjectType().getDescribe().getName();
        if(!m_newListByType.containsKey(sObjectType))
            throw new UnitOfWorkException(String.format('SObject type {0} is not supported by this unit of work', new String[] { sObjectType }));
        m_newListByType.get(sObjectType).add(record);
        if(relatedToParentRecord!=null && relatedToParentField!=null)
            registerRelationship(record, relatedToParentField, relatedToParentRecord);
    }

 
Hi Experts,

There is an email is comes from webservice, in that email we are searching for the policy number with that policy number we are creating case but problem here is that its  reading phone number also and creating case, so i observerd that phone number is coming prefix as "tel,T,telephone,phone,fax,F,+27" if i find anythig like this i need to ignore.
below is the expression we are using. can anyone help me please

public static final String REGEX_PATTERN_POLICY_NUMBER = '[0-9]{6,12}';
How can i redirect to the contact page , once the opportunity record get created. can anyone help me please.
 
/lightning/o/Opportunity/new?defaultFieldValues=Name={!Account.Name},ContactId={!Contact.Id}&backgroundContext=%2Flightning%2Fr%2FContact%2F{!Contact.Id}%2Fview

 
Hi Experts,

I am not Not able to cover the below class handler which works before update , can anyone help me out. please. still its only 53%, majority of the issue is wiht else part which i bolded.
 
public without sharing class Stamp_Case
{
    
    public static void updateBeforeChange(List<SObject> newSobjs, Map<Id,SObject> oldSobjsMap)
    {
        List<Case> newCases = (List<Case>) newSobjs;
        Map<Id, Case> oldCasesMap = (Map<Id, Case>)oldSobjsMap;
        BusinessHours bh = [SELECT Id,SundayStartTime, MondayStartTime, TuesdayStartTime,WednesdayStartTime, ThursdayStartTime, FridayStartTime,SaturdayStartTime, SundayEndTime, MondayEndTime,TuesdayEndTime,WednesdayEndTime, ThursdayEndTime, FridayEndTime,SaturdayEndTime FROM BusinessHours WHERE IsDefault=true];//Quering the businesshours to user in IsWithin function
        system.debug('BusinessHoursBusinessHours  '+bh);
        for(Case cs : newCases)
        {
            Case oldCs = oldCasesMap.get(cs.Id);
            Boolean oldrecordtype= oldcs.RecordType_Name__c.equals('N_L_QNA');
            Boolean oldrecordtype1= oldcs.RecordType_Name__c.equals('L_QNA');
            Boolean newrecordtype = cs.RecordType_Name__c.equals('UW_L_QNA');
            Boolean newrecordtype1= cs.RecordType_Name__c.equals('N_L_QNA');
            string oldCsstatus = oldCasesMap.get(cs.Id).Status; 
            string dayOfWeek=cs.lastmodifieddate.format('EEEE');
            System.debug('Day : ' + dayOfWeek);
            DateTime dT = cs.LastModifiedDate;
            Date myDate = date.newinstance(dT.year(), dT.month(), dT.day());
            System.debug('myDate : ' + myDate );
            String Mon ='Monday';
            String Tue ='Tuesday';
            String Wed ='Wednesday';
            String Thur ='Thursday';
            String Fri ='Friday';
            String Sat= 'Saturday';
            String Sun= 'Sunday';
            
            
            Boolean isWithin = BusinessHours.isWithin(bh.id,  cs.LastModifiedDate);
            
            
            if((oldrecordtype  || oldrecordtype1 ) && (newrecordtype || newrecordtype1) )
            {
                if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
                {
                    
                   
                    cs.Sent_Hours__c= B_BusinessHours.getTimeDifferenceInMinutes(
                        cs.CreatedDate,
                        cs.LastModifiedDate,
                        businessHoursId);
                  
                    
                    Decimal mydecval = cs.Sent_Formula__c;
                    system.debug('mydecvalmydecvalmydecval'+mydecval);
                    Integer myintval = mydecval.intValue(); //Converting Decimal Value to Integer
                    system.debug('myintvalmyintvalmyintval'+myintval);
                    
                   
                    cs.Sent_to__c = B_BusinessHours.addMinutes(
                        myintval,
                        businessHoursId);
                }
                
                **else if (dayOfWeek == Mon)
                {
                    cs.Sent_to__c= DateTime.newInstance(myDate,bh.MondayEndTime); 
                }
                else if(dayOfWeek == Tue)
                {
                    cs.Sent_to__c=  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;
                }
                else if(dayOfWeek == Wed)
                {
                    cs.Sent_to__c=  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;
                }
                else if(dayOfWeek == Thur)
                {
                    cs.Sent_to__c=  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;
                   
                }
                else if(dayOfWeek == Fri)
                {
                    cs.Sent_to__c=  DateTime.newInstance(myDate,bh.FridayEndTime) ;
                }
                else if(dayOfWeek == Sat)
                {
                    Date satdate = myDate- 1;
                    cs.Sent_to__c=  DateTime.newInstance(satdate,bh.FridayEndTime) ;
                }
                else if(dayOfWeek == Sun)
                {
                    Date Sundate=myDate- 2;
                    cs.Sent_to__c=  DateTime.newInstance(Sundate,bh.FridayEndTime) ;**
                }
                
                
            }
            
            if((cs.status =='Emailed to Broker' || cs.status==' Emailed to Distribution') && oldCsstatus != cs.status)
            {
                **if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
                {
                    cs.Dist_Hours__c = B_BusinessHours.getTimeDifferenceInMinutes(
                        cs.CreatedDate,
                        cs.LastModifiedDate,
                        businessHoursId);
                    
                    Decimal mydecval = cs.Dist_Formula__c;
                   
                    Integer myintval = mydecval.intValue();
                    system.debug('myintvalmyintvalmyintval'+myintval);
                    cs.Dist__c= B_BusinessHours.addMinutes(
                        myintval,
                        businessHoursId);
                }
                else if (dayOfWeek == Mon)
                {
                    cs.Dist__c= DateTime.newInstance(myDate,bh.MondayEndTime); 
                }
                else if(dayOfWeek == Tue)
                {
                    cs.Dist__c=  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;
                }
                else if(dayOfWeek == Wed)
                {
                    cs.Dist__c=  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;
                }
                else if(dayOfWeek == Thur)
                {
                    cs.Dist__c=  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;
                  
                }
                else if(dayOfWeek == Fri)
                {
                    cs.Dist__c=  DateTime.newInstance(myDate,bh.FridayEndTime) ;
                }
                else if(dayOfWeek == Sat)
                {
                    Date satdate = myDate- 1;
                    cs.Dist__c=  DateTime.newInstance(satdate,bh.FridayEndTime) ;
                }
                else if(dayOfWeek == Sun)
                {
                    Date Sundate=myDate- 2;
                    cs.Dist__c=  DateTime.newInstance(Sundate,bh.FridayEndTime) ;
                }**
                
            }
            
            if(cs.Process__c=='Verify' && cs.Verify_Date__c== null)
            {
                
                if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
                { 
                    
                    cs.Date_Hours__c= B_BusinessHours.getTimeDifferenceInMinutes(
                        cs.CreatedDate,
                        cs.LastModifiedDate,
                        businessHoursId);
                    
                    Decimal mydecval = cs.Date_Formula__c;
                  
                    Integer myintval = mydecval.intValue();
                   
                    cs.Verify_Date__c= B_BusinessHours.addMinutes(
                        myintval,
                        businessHoursId);
                }
                
                **else if (dayOfWeek == Mon)
                {
                    cs.Verify_Date__c = DateTime.newInstance(myDate,bh.MondayEndTime); 
                }
                else if(dayOfWeek == Tue)
                {
                    cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;
                }
                else if(dayOfWeek == Wed)
                {
                    cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;
                }
                else if(dayOfWeek == Thur)
                {
                    cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;
                   
                }
                else if(dayOfWeek == Fri)
                {
                    cs.Verify_Date__c =  DateTime.newInstance(myDate,bh.FridayEndTime) ;
                }
                else if(dayOfWeek == Sat)
                {
                    Date satdate = myDate- 1;
                    cs.Verify_Date__c =  DateTime.newInstance(satdate,bh.FridayEndTime) ;
                }
                else if(dayOfWeek == Sun)
                {
                    Date Sundate=myDate- 2;
                    cs.Verify_Date__c =  DateTime.newInstance(Sundate,bh.FridayEndTime) ;**
                } 
                
            }
            
            if(cs.Process__c=='Preparation' && cs.Preparation_Date__c== null)
            {
                
                if(isWithin==true && (dayOfWeek == Mon || dayOfWeek == Tue|| dayOfWeek == Wed|| dayOfWeek == Thur|| dayOfWeek == Fri))
              {
                
                cs.Preparation_Date_Hours__c= B_BusinessHours.getTimeDifferenceInMinutes(
                    cs.CreatedDate,
                    cs.LastModifiedDate,
                    businessHoursId);
                
                Decimal mydecval = cs.Preparation_Date_Formula__c;
                
                Integer myintval = mydecval.intValue();
                
                cs.Preparation_Date__c = B_BusinessHours.addMinutes(
                    myintval,
                    businessHoursId);
                
            }
            
            else if (dayOfWeek == Mon)
            {
                **cs.Preparation_Date__c = DateTime.newInstance(myDate,bh.MondayEndTime);** 
            }
            else if(dayOfWeek == Tue)
            {
                **cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.TuesdayEndTime) ;**
            }
            else if(dayOfWeek == Wed)
            {
                **cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.WednesdayEndTime) ;**
            }
            else if(dayOfWeek == Thur)
            {
                cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.ThursdayEndTime) ;
               
            }
            **else if(dayOfWeek == Fri)
            {
                cs.Preparation_Date__c =  DateTime.newInstance(myDate,bh.FridayEndTime) ;
            }
            else if(dayOfWeek == Sat)
            {
                Date satdate = myDate- 1;
                cs.Preparation_Date__c =  DateTime.newInstance(satdate,bh.FridayEndTime) ;
            }
            else if(dayOfWeek == Sun)
            {
                Date Sundate=myDate- 2;
                cs.Preparation_Date__c =  DateTime.newInstance(Sundate,bh.FridayEndTime) ;**
            } 
            
          }
            
        }
        
    }
    
    public static Id businessHoursId
    {
        get
        {
            if (businessHoursId == null)
            {
                businessHoursId = B_BusinessHours.getBusinessHoursId();
            }
            return businessHoursId;
        }
        set;
    }
}


Below is my Test class.

        @isTest
    public class Case_Test{
    
    Public static testMethod void Test_method() 
    {
    
      Id recordtyepe= Schema.SObjectType.Case.getRecordTypeInfosByName().get('- L - QNA').getRecordTypeId();
      Id recordtyepes= Schema.SObjectType.Case.getRecordTypeInfosByName().get('UW - L - QNA').getRecordTypeId();
      List<BusinessHours> bhs=[select id from BusinessHours where IsDefault=true];
     
      case c = new case();
      c.Origin='email';
      c.Status='Assigned';
      c.RecordtypeId= recordtyepe;
      c.Process__c='Verify';
      c.Process__c= 'Preparation';
      insert c;
      c.Process__c='Preparation';
      c.Process__c='Verify';
      c.RecordtypeId =recordtyepes;
      Test.setCreatedDate(c.Id,  datetime.newInstance(2019, 11, 11, 11, 30, 0));
       Test.startTest();
       case cs= [SELECT Id, CreatedDate,LastModifiedDate FROM case  where origin='email' limit 1];
       System.assertEquals(cs.CreatedDate,  DateTime.newInstance(2019,11,11,11,30,0));
       Test.stopTest();
       update c;
     
    }
    }

 
Hi Experts,

I have requirment i need create a button(not java script button because i cant use in lighting) when i click on that button new record page has to open and also i want set a default value in that new record page, can anyone hlep me please.
Hi Experts,

Can anyone help me how out, how to the stop the triggers not to fire any profile using custom setting. Thanks in advance
Hi Experts,

We have requirment where we need to replace Opportunity Proudct with the standard object oportunity product object, so i have edited entire controller code
but problem here is that when i replace stadnardcontroller with the OpportunityLineItem in the visualforce page its not allowing me to work its throwing an error called "Error: List controllers are not supported for OpportunityLineItem    ", 
can anyone help me out, how to fix this issue. 
 
Vf page: 
<apex:page standardController="Product__c" recordSetVar="oppProds" extensions="ProductController" showHeader="false" standardStylesheets="true" sidebar="false"
  docType="html-5.0">
   
    <body>
        <apex:form id="frm">
            <div align="center">
                <div class="h1Div" >
                    <input type="button" id="btnBack1" value="Back" class="sf1buttonSFBlue backButtonControlClass" onClick="javascript: goBack();" style="float: left;margin-top: -5px;margin-right: 15px;height: 35px;"/>
                    <h1>Opportunity Products</h1>
                    <img src="{!$Resource.SF1HeaderLogoSmall}" style="float:right;width: 100px;"/>
                </div>
                <br/>
                <apex:pageMessages id="MESSAGES"/>
            </div>
            
            <div class="sf1divBlock">
                <div class="sf1headerLabel">
                    <apex:outputLabel value="{!cOpp.Name}" style="margin-left: 5px;"/>
                </div>
                <br/>
                <apex:outputPanel id="OPPPRODPANEL">
                    <table id="OPPPRODTABLE" class="sf1Table" style="width:100%;">
                        <thead>
                            <tr>
                                <th width="50%"> Product </th>
                                <th width="12%"> Include in next quote </th>
                                <th width="22.5%"> Quantity </th>
                                <th width="22.5%"> Requested Price </th>
                                <th class="DMLActions" width="5%"> Action </th>
                            </tr>
                        </thead> 
                        <tbody>
                            <apex:variable var="rowClass" value="odd"/>
                            <apex:variable var="rowNum" value="{!0}"/> 
                            <apex:repeat value="{!clstOppProds}" var="oppProd">
                                <tr class="{!rowClass}">
                                    <td>
                                        <div class="scrollable-dropdown-menu">
                                            <input type="text" id="prodName{!rowNum}" name="prodName{!rowNum}" class="sf1Input"/>
                                        </div>
                                        <script>
                                            //Initialize the type ahead
                                            var prodName{!rowNum} = jQuery('#prodName{!rowNum}');
                                            if(prodName{!rowNum}){
                                                prodName{!rowNum}.typeahead(
                                                    {
                                                        minLength: 3,
                                                        highlight: true
                                                    },
                                                    {
                                                        limit: 999,
                                                        display: 'value',
                                                        source: function(searchText, syncCallback, asyncCallback) {
                                                            searchText = searchText.split('\\').join('\\\\');
                                                            searchText = searchText.split('\'').join('\\\'');
                                                            var sObj = new SObjectModel.Product2();
                                                            sObj.retrieve({ 
                                                                where:{
                                                                    or:{
                                                                        Name: {like: searchText + '%'},
                                                                        or:{
                                                                            Description: {like: searchText + '%'},
                                                                            Product2: {like : searchText + '%'}
                                                                        }
                                                                    },
                                                                    and:{
                                                                        Active__c: {eq: true},
                                                                        or:{
                                                                            RecordTypeId: {eq: '{!ProductRTId}'},
                                                                            and:{
                                                                                Status__c: {eq: 'Approved'},
                                                                                Product__c: {eq: ''}
                                                                            }
                                                                        }
                                                                    }
                                                                },
                                                                orderby: [{Name: 'ASC'}],
                                                                limit:999},
                                                                function(err,records){
                                                                    if(err){
                                                                        alert(err);
                                                                    } else {
                                                                        var dataList = [];
                                                                        var maxLength = 1;
                                                                        jQuery.each(records, function(index, record){
                                                                            dataList.push({
                                                                                id: record.get('Id'),
                                                                                value: jQuery('<div/>').html(record.get('Name')).text(),
                                                                                code: jQuery('<div/>').html(record.get('Type_Code__c')).text(),
                                                                                desc2: jQuery('<div/>').html(record.get('Description')).text()
                                                                            });
                                                                        });
                                                                        asyncCallback(dataList);
                                                                    }
                                                                }
                                                            ) 
                                                        },
                                                        templates: {
                                                            suggestion: function (data) {
                                                                var desc = data.value;
                                                                if(data.desc2) desc += ' - ' + data.desc2;
                                                                return '<div><table class="tt-table"><tr><td class="tt-table-td1">' + desc + '</td><td class="tt-table-td2">' + data.code + '</td></tr></table></div>';
                                                            }
                                                        }
                                                    }
                                                ).on('typeahead:selected', function (object, datum) {
                                                    setProd({!rowNum},datum.id,datum.value);
                                                }).on('typeahead:autocompleted', function (object, datum) {
                                                    setProd({!rowNum},datum.id,datum.value);
                                                }).on('typeahead:change', function (event, data) {
                                                    //Reset the fields to blank
                                                    
                                                });
                                            }
                                            prodName{!rowNum}.typeahead('val', '{!JSENCODE(oppProd.Product__r.Name)}');
                                        </script>
                                    </td>
                                    
                                    <td>
                                        <apex:inputField value="{!oppProd.Next_Quote__c}" style="width:30px; height:20px;"/>
                                    </td>
                                    <td>
                                        <apex:inputField value="{!oppProd.Quantity__c}" styleClass="sf1Input"/>
                                    </td>
                                    <td>
                                        <apex:inputField value="{!oppProd.Price__c}" styleClass="sf1Input"/>
                                    </td>
                                    <td valign="top" class="DMLActions">
                                        <input type="button" id="btnDelete{!oppProd.id}" class="sf1buttonDelete" value="" onClick="removeRow('{!rowNum}');" />
                                    </td>
                                </tr>
                                <apex:variable var="rowClass" value="{!IF(rowClass == 'odd','','odd')}"/> 
                                <apex:variable var="rowNum" value="{!rowNum + 1}"/> 
                            </apex:repeat>
                        </tbody>
                    </table>
                </apex:outputPanel>
                <table class="sf1InputTableTwoCol">
                    <tr>
                        <td>
                            <input type="button" id="btnBack" class="sf1buttonSFBlue" value="Back" onClick="goBack();" />
                            <input type="button" id="btnAddNew" class="sf1buttonSFBlue" value="Add New" onClick="addNew();" />
                            <input type="button" id="btnSave" class="sf1buttonSFBlue" value="Save" onClick="doSave();" />
                        </td>
                    </tr>
                </table>
            </div>
            
            <apex:actionFunction name="setProd" action="{!setProd}" reRender="MESSAGES" status="status">
                <apex:param name="p1" value="" assignTo="{!selectedRowNum}"/>
                <apex:param name="p2" value="" assignTo="{!selectedRowProdId}"/>
                <apex:param name="p3" value="" assignTo="{!selectedRowProdName}"/>
            </apex:actionFunction>
            <apex:actionFunction name="removeRow" action="{!removeRow}" reRender="MESSAGES,OPPPRODPANEL" status="status">
                <apex:param name="p1" value="" assignTo="{!selectedRowNum}"/>
            </apex:actionFunction>
            <apex:actionFunction name="goBack" action="{!cancel}" reRender="MESSAGES" status="status"/>
            <apex:actionFunction name="doSave" action="{!doSave}" reRender="MESSAGES" status="status"/>
            <apex:actionFunction name="addNew" action="{!addNew}" reRender="MESSAGES,OPPPRODPANEL" status="status"/>
            
            <apex:actionstatus id="status">
                <apex:facet name="start">
                    <div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb;height: 100%;opacity:0.65;width:100%;">
                        <div class="waitingHolder" style="top:220px;">
                            <img class="waitingImage" src="{!$Resource.Salesfroce1Loading}" title="Processing..." />
                        </div>
                    </div>
                </apex:facet> 
            </apex:actionstatus>
        </apex:form>
    </body>
</apex:page>


Apex class:

public class ProductController {
    public Opportunity cOpp {get;set;}
    public Integer selectedRowNum {get;set;}
    public String selectedRowProdId {get;set;}
    public String selectedRowProdName {get;set;}
    public List<OpportunityLineItem> clstOppProds {get;set;}
    public List<OpportunityLineItem> clstDelOppProds {get;set;}
    public String getJDEProductRTId(){
        return [SELECT Id FROM RecordType WHERE SObjectType = 'Product2' AND Name = 'New Products' LIMIT 1].get(0).Id;
    }
	
	   public ProductController(ApexPages.StandardSetController ssc) {
        selectedRowNum = null;
        selectedRowProdId = null;
        selectedRowProdName = null;
        String oppId = ApexPages.currentPage().getParameters().get('id');
        cOpp = null;
        for(Opportunity o : [SELECT Id,Name FROM Opportunity WHERE Id = :oppId]) cOpp = o;
        clstOppProds = new List<OpportunityLineItem>();
        clstDelOppProds = new List<OpportunityLineItem>();
        if(oppId != null) clstOppProds = [SELECT Id,Opportunityid,Next_Quote__c,Product2id,Product2.Name,Quantity__c,Price__c FROM OpportunityLineItem WHERE Opportunityid = :oppId];
    }
	
	 public PageReference setProd(){
         PageReference pg = null;
         OpportunityLineItem op = clstOppProds.get(selectedRowNum);
         Product2 pt = new Product2(id=selectedRowProdId,name=selectedRowProdName);
         op.Product2id = selectedRowProdId;
         op.Product2.Name = pt.Name;
         return pg;
     }
	 
	 public PageReference removeRow(){
         PageReference pg = null;
         OpportunityLineItem op = clstOppProds.remove(selectedRowNum);
         if(op.Id != null) clstDelOppProds.add(op);
         return pg;
     }
	 
	   public PageReference addNew(){
         PageReference pg = null;
         clstOppProds.add(new OpportunityLineItem(Opportunityid=cOpp.Id));
         return pg;
     }
	 public PageReference doSave(){
         PageReference pg = null;
         SavePoint sp = Database.setSavePoint();
         try{
             delete clstDelOppProds;
             upsert clstOppProds;
             pg = new PageReference('/'+cOpp.Id);
         }catch(Exception e){
             Database.rollback(sp);
             Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, e.getMessage()));
         }
         return pg;
     }
}

 
Hi Experts,

I have small requirement where i need to filter a long text area field called Desc__c which i am not able to do that can anyone help me please.

OrderItem oli1 = new OrderItem ();
        oli1.Orderid = order.Id;
        oli1.Desc__c= 'Test OLI 1'; 
      insert oli1;


 OrderItem oli2 = [SELECT Id, Orderid
                    FROM OrderItem WHERE  Desc__c = 'Test OLI 1' LIMIT 1];

In this filter condition its throwing an error can anyone help me please thanks in adavance
Hi Experts,

Can anyone helps me , while running my test class i am getting below error. Below is my code anyone help  me please. the area which i made bold in the insert command i receiving this can anyone helps me please.

DUPLICATE_VALUE, This price definition already exists in this price book: []   


Account a = new Account(Name='testAccount',RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Customer').getRecordTypeId()); //Added by Purnima for Story S-562343
         insert a; 
        
        Id pricebookId = Test.getStandardPricebookId();
        
        Product2 prod = new Product2(Name = 'Laptop X200', 
                                     Family = 'Hardware');
        insert prod;
        
     
        
        /*PricebookEntry standardPrice = new PricebookEntry(
            Pricebook2Id = pricebookId, Product2Id = prod.Id,
            UnitPrice = 10000, IsActive = true);
        insert standardPrice;*/
        
        PriceBookEntry stdPriceBookEntry = new PriceBookEntry();
        stdPriceBookEntry.Product2Id=prod.Id;
        stdPriceBookEntry.Pricebook2Id=pricebookId;
        stdPriceBookEntry.UnitPrice=2000;
        stdPriceBookEntry.IsActive=true;
        insert stdPriceBookEntry;

        
        Pricebook2 customPB = new Pricebook2(Name='Custom Pricebook', isActive=true);
        insert customPB;
        
        PricebookEntry customPrice = new PricebookEntry(
            Pricebook2Id = customPB.Id, Product2Id = prod.Id,
            UnitPrice = 12000, IsActive = true);
        insert customPrice;
         Product_Type__c productType = new Product_Type__c();        
        productType.Product_Type_Code__c = 'End';
      
        insert productType;
        
        
        Opportunity opp = new Opportunity(Name='Test', 
                                          Account = a, 
                                         // Product__c='GRI Retail',
                                          NextStep='test',
                                          PriceBook2 = customPB,
                                          CloseDate = System.today(),
                                          AccountId=a.Id, 
                                         // Opportunity_Name__c='testOpp',
                                         // Product_Family__c='Retail',
                                        Industry__c='Other',
                                        Description='TestTestTest',
                                          StageName='Closed Won - One Time' 
                                          );
       
       insert opp; 
        
    
     
    List<Opportunity_Product__c> oppProdList = new List<Opportunity_Product__c>();
     for(Integer i=1;i<=10;i++)
     oppProdList.add(new Opportunity_Product__c (Opportunity__c = opp.Id,Product__c = productType.id));
     
     System.debug('test@@@'+ oppProdList );
        
        insert oppProdList;
        
        

     
     
     ApexPages.StandardSetController sc = new ApexPages.StandardSetController(oppProdList);
    
     
    
      PageReference pageRef = Page.OpportunityProducts;
        pageRef.getParameters().put('id', String.valueOf(''));
        Test.setCurrentPage(pageRef);
    
    
    //Test.setCurrentPageReference(Page.OpportunityProducts);
    
    OpportunityController obj= new OpportunityController(sc);
    obj.selectedRowNum=1;
    obj.selectedRowProdId=productType.id;
    obj.selectedRowProdName=productType.Name;
    obj.cOpp=opp;
    List<Opportunity_Product__c> testopp= new List<Opportunity_Product__c>();
    obj.clstOppProds=oppProdList;
    List<Opportunity_Product__c> testOpps= new  List<Opportunity_Product__c>();
    obj.clstDelOppProds=oppProdList;
    
    obj.getJDEProductRTId();
   
    //Product_Type__c pt = new Product_Type__c(id='test', name='test');
    System.debug('clstOppProds==>' + obj.clstOppProds);
        System.debug('clstDelOppProds==>' + obj.clstDelOppProds);
    
    PageReference pg = obj.doSave(); 
    PageReference pg1 = obj.addNew(); 
    //PageReference pg3 = obj.setProd();
    PageReference pg2 = obj.removeRow(); 
    
 
Hi Experts,
I wrote one batch class with contractor like below. but when i was try to run my test class i am getting an error that constructor is not defind. below is my test class as well , can anyone help me plesae . thanks in advance
private  list<String> sOrganization;
public UpdateAccountCallList(String[] sorg) {
sOrganization = sorg;
}
 
 
Test class:
 
@isTest
public class AccountUpdatecallistBatchJobTest
{
static testMethod void testMethod1()
{
List<Account> lstAccount= new List<Account>();
List<Account> lstAccount1= new List<Account>();
List<Account> lstAccount2= new List<Account>();
List<Account> lstAccount3= new List<Account>();
List<Account> lstAccount4= new List<Account>();
List<Account> lstAccount5= new List<Account>();
for(Integer i=0 ;i <5;i++)
{
Account acc = new Account();
acc.Name =’Name’+i;
acc.Call_List_Frequency__c=8;
acc.Call_List__c=true;
acc.Call_List_Start_Date__c=system.today()-1;
acc.Call_List_Preferred_Day__c=’MOnday’;
date myDate = date.today();
acc.Call_List_Next_Preferred_Date__c=myDate.toStartofWeek()+0;
Account acc1 = new Account();
acc1.Name =’Name1’+i;
acc1.Call_List_Frequency__c=6.0;
acc1.Call_List__c=true;
acc1.Call_List_Start_Date__c=system.today()-1;
acc1.Call_List_Preferred_Day__c=’Tuesday’;
date myDate1 = date.today();
acc1.Call_List_Next_Preferred_Date__c=myDate1.toStartofWeek()+1;
lstAccount1.add(acc1);
Account acc2 = new Account();
acc2.Name =’Name1’+i;
acc2.Call_List_Frequency__c=6.0;
acc2.Call_List__c=true;
acc2.Call_List_Start_Date__c=system.today()+1;
acc2.Call_List_Preferred_Day__c=’Wednesday’;
date myDate2 = date.today();
acc2.Call_List_Next_Preferred_Date__c=myDate2.toStartofWeek()+2;
lstAccount2.add(acc2);
Account acc3 = new Account();
acc3.Name =’Name1’+i;
acc3.Call_List_Frequency__c=6.0;
acc3.Call_List__c=true;
acc3.Call_List_Start_Date__c=system.today()-1;
acc3.Call_List_Preferred_Day__c=’Thursday’;
date myDate3 = date.today();
acc3.Call_List_Next_Preferred_Date__c=myDate3.toStartofWeek()+3;
lstAccount3.add(acc3);
Account acc4 = new Account();
acc4.Name =’Name1’+i;
acc4.Call_List_Frequency__c=6.0;
acc4.Call_List__c=true;
acc4.Call_List_Start_Date__c=system.today()-1;
acc4.Call_List_Preferred_Day__c=’Friday’;
date myDate4 = date.today();
acc4.Call_List_Next_Preferred_Date__c=myDate4.toStartofWeek()+4;
lstAccount4.add(acc4);
Account acc5 = new Account();
acc5.Name =’Name1’+i;
acc5.Call_List_Frequency__c=6.0;
acc5.Call_List__c=true;
acc5.Call_List_Start_Date__c=system.today()-1;
acc5.Call_List_Preferred_Day__c=’None’;
acc5.Call_List_Next_Preferred_Date__c=system.today();
lstAccount5.add(acc5);
}
insert lstAccount;
insert lstAccount1;
insert lstAccount2;
insert lstAccount3;
insert lstAccount4;
insert lstAccount5;
Test.startTest();
UpdateAccountCallList obj = new UpdateAccountCallList();
obj.currentweek=9;
DataBase.executeBatch(obj);
Test.stopTest();
}
}