• Jayaramu T 9
  • NEWBIE
  • 20 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 25
    Questions
  • 11
    Replies
I am getting following errors in below code

Field is not writeable: AccountShare.AccountAccessLevel
 Field is not writeable: AccountShare.CaseAccessLevel
 Field is not writeable: AccountShare.OpportunityAccessLevel
 Field is not writeable: AccountShare.AccountId
 Field is not writeable: AccountShare.UserOrGroupId



if(z==0 && resgroup.get(asset.Reseller__c)!=null){
                    Accountshare ashare = new AccountShare();
                    ashare.AccountAccessLevel='Edit';
                    ashare.CaseAccessLevel='None';
                    ashare.OpportunityAccessLevel='None';
                    ashare.AccountId=asset.AccountId;
                    ashare.userOrGroupId=resgroup.get(asset.Reseller__c);
                    newshares.add(ashare);
                }
while saving i a getting following error 
Error: Compile Error: Missing ';' at 'Closed' at line 439 column 120

in above query Status is picklist field values like 'Closed','New',Reopen'
// Returns a dynamic SOQL statement for the whole object, includes only creatable fields since we will be inserting a cloned result of this query
    public static string getCreatableFieldsSOQL(String objectName){
        
        String selects = '';
        
        //if (whereClause == null || whereClause == ''){ return null; }
        
        // Get a map of field name and field token
        Map<String, Schema.SObjectField> fMap = Schema.getGlobalDescribe().get(objectName.toLowerCase()).getDescribe().Fields.getMap();
        list<string> selectFields = new list<string>();
        
        if (fMap != null){
            for (Schema.SObjectField ft : fMap.values()){ // loop through all field tokens (ft)
                Schema.DescribeFieldResult fd = ft.getDescribe(); // describe each field (fd)
                //if (fd.isCreateable()){ // field is creatable
                    selectFields.add(fd.getName());
                //}
            }
        }
        
        if (!selectFields.isEmpty()){
            for (string s:selectFields){
                selects += s + ',';
            }
            if (selects.endsWith(',')){selects = selects.substring(0,selects.lastIndexOf(','));}
            
        }
        
        return 'SELECT ' + selects + ' FROM ' + objectName;
        
    }
Critical Updates - Add a Namespace Prefix to Query Parameters and pageReference.state Properties

How to Activate and test this update in Org and pleae provide me if any one have examples on this.
I have a field called ERP Instance Id. This field comes under Service Contracts.
I have ERP Instance Id. I wanted to know the Service Contract ID based on that ERP Instance Id at SFDC.
User-added imageUser-added image
global class BatchDeactivateUsers implements Database.Batchable<sobject> {
    global Database.QueryLocator start(Database.BatchableContext BC) {
        Map<String,daystodeactivateuser__c> csdaystodeactivateuser = daystodeactivateuser__c.getAll();
        integer noOfDays=0;
        if(csdaystodeactivateuser!=null){
            noOfDays = integer.ValueOf(csdaystodeactivateuser.get('numberofdaysemailnotificationsent').Numberofdays__c);
        }
        string query = 'SELECT Id,isActive,LastLoginDate,UserDeactivationDate__c FROM User where isActive=true and UserDeactivationDate__c!=null and UserDeactivationDate__c = TODAY and lastlogindate < LAST_N_DAYS:'+noOfDays;
        if (!Test.IsRunningTest()) {
            return Database.getQueryLocator(query);
        } else {
            return Database.getQueryLocator('SELECT Id,isActive,LastLoginDate,UserDeactivationDate__c FROM User limit 1');
        }
    }
    global void execute(Database.BatchableContext BC, List<user> userList) {
        for (User usrRec: userList) {
            usrRec.isActive = false;
            if(usrRec.contactId!=null){
                usrRec.isPortalenabled = false;  
            }
        }
        if (userList.size() > 0 && !Test.isRunningTest()) {
            update userList;
        }
    }
    global void finish(Database.BatchableContext BC) {}
}
public static void onAfterUpdate(Case[] oldRecords, Case[] updatedRecords, Map<ID, Case> oldRecordMap)
  {
    autoAssignCase(updatedRecords);
    // Take new cases, bulkified
    LIST<Case> caselist = Trigger.new;
    // Find all Custom Settings defining default Case Milestones
    LIST<CaseMilestoneSetting__c> CMileSs = [select ID, CaseCriteria__c, MilestoneID__c from CaseMilestoneSetting__C];
    // Loop through each Custom Setting for Case Milestones
    //Fixed LOOp Standard case settings
    Set<Id> mstoneID = new Set<Id>();
      String alias;
      List<CaseMilestone> setmstones ;
    List<CaseMilestone> lp_setmstones = new List<CaseMilestone>();
    for (CaseMilestoneSetting__c CMileS : CMileSs){
        mstoneID.add(CMileS.MilestoneID__c);
        if(CMileS.CaseCriteria__c != null){
            alias = CMileS.CaseCriteria__c;
        }
    }
      
       if(system.test.isRunningTest())
            setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
else
   setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE '+      alias+   'AND CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
                                                      
        // Update the CompletionDate for each CaseMilesone
        for (CaseMilestone updatemstone : setmstones){
            updatemstone.CompletionDate= Datetime.now();
        }
        // Execute the update for all the Milestones in this set
        lp_setmstones.addAll(setmstones);
  
    if(lp_setmstones.size()>0)
    {
        // Execute the update for all the Milestones in this set
        update lp_setmstones;
    }
    Map<ID,Case> installCases = new Map<ID,Case>();
    ID InstallID;
    List<RecordType> installTypes = [SELECT ID, DeveloperName FROM RecordType WHERE sObjectType='Case' AND DeveloperName='Installation_Report' LIMIT 1];
    if(installTypes.size()>0){
        InstallID=installTypes[0].Id;
    }
    for(Case c : updatedRecords){
        if(c.IsClosed && !oldRecordMap.get(c.id).IsClosed && c.RecordTypeID==InstallID && c.AssetId!=null &&c.Status!='Closed As Duplicate'){
            installCases.put(c.AssetId,c);
        }
    }
    Asset_Util.UpdateAssetInstall(installCases);
    //Porcess Builder - Case - update asset fields
    updateAssetFields(updatedRecords);
  }
Test class
---------------------------------
@istest
private class RPUDashboardBatchTest{
  @testSetup static void setup(){
 
      Integer pastYear = Date.today().addYears(-2).year();
      Date pastDate = Date.newInstance(pastYear, 01, 01);
      Date currentDate =Date.today();
      String blankVal ='';
 
      Product2 pro= new Product2();
      pro.Product_Group__c='Consumer Products';
      pro.Product_Collection__c='3D Printers';
      pro.Product_Category__c='CubeX';
      pro.Name='Common34';
      insert pro;
 
    
      Asset[] assetRecList= new List<Asset>();
     
     
          
       Integer currYear = Date.today().year();   
       for (Integer z=Date.today().addYears(-2).year();z<=Date.today().year();z++) {
           Asset ast;
           for (Integer assetMonth=1; assetMonth<=12;assetMonth++){
                ast=new Asset();          
                ast.Name='Assettest';
                ast.Ship_Date__c = date.newInstance(z, assetMonth+1, 1);
                if((assetMonth <= Date.today().month() && z==Date.today().year()) || (z < Date.today().year()))
                ast.InstallDate=date.newInstance(z, assetMonth, 1);
                ast.Product2Id = pro.Id;
              
                System.debug('@@ShipYear'+ast.Ship_Date__c);
                System.debug('@@assetMonth'+ast.InstallDate);
                assetRecList.add(ast);
            }
       }
      
     
       insert assetRecList;
     
       Asset as1= new Asset();
            as1.Name='Assettest';
            as1.Ship_Date__c = date.newInstance(2016, 1, 1);
            as1.InstallDate=date.newInstance(2016, 1, 1);
            as1.Product2Id = pro.Id;
          
            insert as1;
     
      List<Asset> lsAsset = [select id, Product_Group__c, Product_Collection__c, Product_Category__c from Asset where id IN:assetRecList];
      System.debug('@@lsAsset'+lsAsset);
    
      Integer assetCount= [select count() from Asset where id IN: assetRecList];
      //System.assertEquals(3, assetCount);
      Asset j=assetRecList[0];
       id u=j.id;
    
    
      Issue__c iss=new Issue__c();
      iss.Name='Issuename1';
      iss.Active__c=True;    
      iss.Product_Group__c='Consumer Products';
      iss.Product_Collection__c='3D Printers';
      insert iss;
    
      List<RecordType> i=[Select id,Name from RecordType where Name =:'SalesForce Support'];
      Id k;
   
      RecordType p=i[0];
      k=p.id;
   
    
   //Marwin Change: Validation Rule of Contact_Cannot_Equal_Case_Creator, a case must not have a recordId of 01280000000GFJM"Installation Report"
      Id InstReport = [Select id from RecordType where SobjectType = 'Case' and Name =:'Installation Report' limit 1].id;    
     Case[] CaseList= new List<Case>();
     Integer assetIndex =0;
      for (Integer x=Date.today().addYears(-2).year();x<=Date.today().year();x++) {
            Case cs;
            for (Integer CaseMonth=1; CaseMonth<=12;CaseMonth++){
                cs =new Case();
                cs.RecordTypeId = InstReport ; //change from InstReport to k
                cs.bypassvalidation__c = true;
                cs.Status='Open';
                cs.Description='testdescription';       
                cs.AssetID=assetRecList[assetIndex].Id;
                if((CaseMonth <= Date.today().month() && x==Date.today().year()) || (x < Date.today().year()))
                cs.Install_Completion_Date__c=date.newInstance(x, CaseMonth, 1);
                CaseList.add(cs);
                system.debug('***CaseInstallDate***'+cs.Install_Completion_Date__c);
                assetIndex++;
            }
          
      }
      system.debug('***CaseList***'+CaseList);
      insert CaseList;
    
      Case[] CaseList2= new List<Case>();
    
            for (Integer MonthCounter=1; MonthCounter<=12;MonthCounter++){
                Case cs =new Case();
                cs.RecordTypeId= k ;
                cs.Status='Open';
                cs.Description='testdescription';
                cs.AssetID=assetRecList[MonthCounter-1].Id;
                CaseList2.add(cs);
            }
          
    
      system.debug('***CaseList2***'+CaseList2);
      insert CaseList2;
    
      Case_Issue__c[] CaseIssueList= new List<Case_Issue__c>();
      Integer casecount=0;
      for (Integer y=Date.today().addYears(-2).year();y<=Date.today().year();y++) {
            Case_Issue__c csiss;
            for (Integer MonthCount=1; MonthCount<=12;MonthCount++){
                if((MonthCount <= Date.today().month() && y==Date.today().year()) || (y < Date.today().year())){
                    csiss =new Case_Issue__c();
                    csiss.Case__c = CaseList[casecount].id;
                    csiss.Issue__c= iss.id;
                    csiss.Product_Group__c='Consumer Products';
                    csiss.Product_Collection__c='3D Printers';
                    //Integer installedYear = csiss.asset.InstallDate.year();
                    casecount++;
                    CaseIssueList.add(csiss);
                }
            }
          
      }
      system.debug('***CaseIssueList***'+CaseIssueList);
      insert CaseIssueList;
    
    
      RPU_OOB_Dashboard_Settings__c custSettings = new RPU_OOB_Dashboard_Settings__c();
      custSettings.Name = 'RPUBatchRunTime';
      custSettings.Dashboard_Run_Date__c = system.now();
      custSettings.Status__c = 'Incomplete';
      insert custSettings;
    
    }
  
    public static testmethod void rputest(){
  
  
    test.starttest();
    setup();
    RPUDashboardBatch rs=new RPUDashboardBatch();
    rs.currentDate=date.newInstance(Date.today().year()+1, 1, 1);
    Database.executebatch(rs,200);
    test.stoptest();
  
  
    }
  
    static testMethod void createData(){
    test.starttest();
  
    Account  act = new Account(Name= RPUDashboardBatch.generateRandomString() +'_' +'test', BillingCountryCode='KR');
    insert act;
     Product2 product2_1 = new Product2(
          Name = 'NFR - Freeform Plus',
          CanUseRevenueSchedule = false,
          IsActive = true,
          CurrencyIsoCode = 'USD',
          fw2__Non_Installment__c = false,
          fw2__Recurring__c = false,
          Published__c = true,
          IsFlex__c = true,
          Asset_Tracking__c = false,
          ERP_Taxable_Flag__c = false,
          Servicing_Only__c = false,
          IsEDU__c = false,
          ERP_COMS_NL_TRACKABLE__c = false,
          Asset_Tracking_Override__c = false,
          CPQNewSale__c = false,
          Product_Collection__c ='Geomagic'
        );
        insert product2_1;
    Asset ass = new Asset(Name= RPUDashboardBatch.generateRandomString() +'_' +'test', AccountId=act.id,Product2ID=product2_1.ID);
     insert ass;
     Reseller__c resell2 = new Reseller__c(Name='non-user test',Account__c=act.id);
     insert resell2;
     Opportunity opp = new Opportunity(Name= RPUDashboardBatch.generateRandomString() +'_' +'test-op',AccountID=act.ID,Rapidform_Reseller__c=resell2.ID,StageName='Qualified',CloseDate=Date.today(),FlexNetID__c='12345');
     insert opp;
     test.stoptest();
     }
   }
FlowApplication <info@salesforce.com>

Error element myDecision (FlowDecision).
The flow failed to access the value for myVariable_current.Product2.Product_Category__c because it hasn't been set or assigned.

Flow Details
Flow Name: Asset_Product_Category
Type: Record Change Process
Version: 1
Status: Active
Org: 3D Systems, Inc. (00D3D000000DPRO)
Flow Interview Details
Interview Label: Asset_Product_Category-5_InterviewLabel
Current User: Salesforce CPQ (00534000009QVTC)
Start time: 11/16/2018 3:13 AM
Duration: 0 seconds
How the Interview Started
Salesforce CPQ (00534000009QVTC) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = Asset (02i34000006VTtTAAW)
myVariable_current = Asset (02i34000006VTtTAAW)
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!$Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "11/16/2018 3:13 AM"
DECISION: isChangedDecision2_myRule_1_Product2Id
Skipped this outcome because its conditions weren't met: isChangedRule_2_myRule_1_Product2Id
Outcome conditions:
1. {!myVariable_old} (Asset (02i34000006VTtTAAW)) Is null false
2. {!myVariable_old.Product2Id} (null) Does not equal {!myVariable_current.Product2Id} (null)
Logic: All conditions must be true (AND)

Executed the default outcome

Salesforce Error ID: 2018615494-11105 (-2052676383)
private static testmethod void oobbatchtest(){
    
    test.starttest();
    setup();
    OOBDashboardBatch rs=new OOBDashboardBatch();
    Database.executebatch(rs,200);
    test.stoptest();
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CaseTrigger:
execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 02i34000009s1hjAAA;
first error: CANNOT_EXECUTE_FLOW_TRIGGER, We can't save this record because the “Asset Product Categoryv1.4” process failed.
Give your Salesforce admin these details. This error occurred when the flow tried to update records:
LIMIT_EXCEEDED: System.LimitException: Too many SOQL queries: 101. You can look up ExceptionCode values in the SOAP API Developer Guide.: [] Class.CaseTriggerHandler.updateAssetFields: line 261, column 1 Class.CaseTriggerHandler.onAfterUpdate: line 231, column 1 Trigger. 

could you please follow the below code.
 
On the Opportunity object, prevent non-admin users from modify the Opportunity Name once Probability is greater than 50% and prevent Opportunity from being deleted if Probability greater than or equal to 75% (Please show code as necessary)
onclick="javascript:if ('{!selectedAccount}' != 'NEW' && '{!selectedAccount}' != 'NONE' ) {var newWindow = window.open('/{!selectedAccount}/p', 'accountview', 'top=40, left=40,scrollbars=yes, height=450, width=800');newwindow.focus();}
could you please let me know how can i use line breks in "visualforce email templates" ?
Error: Unknown property 'core.email.template.EmailTemplateComponentController.Account'


<messaging:emailTemplate subject="New email and New Case" recipientType="User" relatedToType="Case">
<messaging:plainTextEmailBody >
*** CASE EMAIL ALERT For NEW CASE***

The following case has a new inbound email associated with it and it has been reopened:

Case: {!relatedTo.CaseNumber}: {!relatedTo.Subject}
Web name: {!relatedTo.SuppliedName}
Web company: {!relatedTo.SuppliedCompany}
Web e-mail: {!relatedTo.SuppliedEmail}
Web phone number: {!relatedTo.SuppliedPhone}

Company: {!Account.Name}
Contact Name: {!Contact.Name}
Contact e-mail: {!Contact.Email}
Contact phone number: {!Contact.Phone}
Case #: {!Case.CaseNumber}
Subject: {!Case.Subject}
Description:
{!Case.Description}

Click on the link to access the case: {!Case.Link}</messaging:plainTextEmailBody>
</messaging:emailTemplate>
I want to create custom setting for "new case creation after 7 days" in future it may increase to 30 days also and How to refer this custom setting in " Process Builder"?
public static void onAfterUpdate(Case[] oldRecords, Case[] updatedRecords, Map<ID, Case> oldRecordMap)
  {
    autoAssignCase(updatedRecords);
    // Take new cases, bulkified
    LIST<Case> caselist = Trigger.new;
    // Find all Custom Settings defining default Case Milestones
    LIST<CaseMilestoneSetting__c> CMileSs = [select ID, CaseCriteria__c, MilestoneID__c from CaseMilestoneSetting__C];
    // Loop through each Custom Setting for Case Milestones
    //Fixed LOOp Standard case settings
    Set<Id> mstoneID = new Set<Id>();
      String alias;
      List<CaseMilestone> setmstones ;
    List<CaseMilestone> lp_setmstones = new List<CaseMilestone>();
    for (CaseMilestoneSetting__c CMileS : CMileSs){
        mstoneID.add(CMileS.MilestoneID__c);
        if(CMileS.CaseCriteria__c != null){
            alias = CMileS.CaseCriteria__c;
        }
    }
      
       if(system.test.isRunningTest())
            setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
else
   setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE '+      alias+   'AND CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
                                                      
        // Update the CompletionDate for each CaseMilesone
        for (CaseMilestone updatemstone : setmstones){
            updatemstone.CompletionDate= Datetime.now();
        }
        // Execute the update for all the Milestones in this set
        lp_setmstones.addAll(setmstones);
  
    if(lp_setmstones.size()>0)
    {
        // Execute the update for all the Milestones in this set
        update lp_setmstones;
    }
    Map<ID,Case> installCases = new Map<ID,Case>();
    ID InstallID;
    List<RecordType> installTypes = [SELECT ID, DeveloperName FROM RecordType WHERE sObjectType='Case' AND DeveloperName='Installation_Report' LIMIT 1];
    if(installTypes.size()>0){
        InstallID=installTypes[0].Id;
    }
    for(Case c : updatedRecords){
        if(c.IsClosed && !oldRecordMap.get(c.id).IsClosed && c.RecordTypeID==InstallID && c.AssetId!=null &&c.Status!='Closed As Duplicate'){
            installCases.put(c.AssetId,c);
        }
    }
    Asset_Util.UpdateAssetInstall(installCases);
    //Porcess Builder - Case - update asset fields
    updateAssetFields(updatedRecords);
  }
Test class
---------------------------------
@istest
private class RPUDashboardBatchTest{
  @testSetup static void setup(){
 
      Integer pastYear = Date.today().addYears(-2).year();
      Date pastDate = Date.newInstance(pastYear, 01, 01);
      Date currentDate =Date.today();
      String blankVal ='';
 
      Product2 pro= new Product2();
      pro.Product_Group__c='Consumer Products';
      pro.Product_Collection__c='3D Printers';
      pro.Product_Category__c='CubeX';
      pro.Name='Common34';
      insert pro;
 
    
      Asset[] assetRecList= new List<Asset>();
     
     
          
       Integer currYear = Date.today().year();   
       for (Integer z=Date.today().addYears(-2).year();z<=Date.today().year();z++) {
           Asset ast;
           for (Integer assetMonth=1; assetMonth<=12;assetMonth++){
                ast=new Asset();          
                ast.Name='Assettest';
                ast.Ship_Date__c = date.newInstance(z, assetMonth+1, 1);
                if((assetMonth <= Date.today().month() && z==Date.today().year()) || (z < Date.today().year()))
                ast.InstallDate=date.newInstance(z, assetMonth, 1);
                ast.Product2Id = pro.Id;
              
                System.debug('@@ShipYear'+ast.Ship_Date__c);
                System.debug('@@assetMonth'+ast.InstallDate);
                assetRecList.add(ast);
            }
       }
      
     
       insert assetRecList;
     
       Asset as1= new Asset();
            as1.Name='Assettest';
            as1.Ship_Date__c = date.newInstance(2016, 1, 1);
            as1.InstallDate=date.newInstance(2016, 1, 1);
            as1.Product2Id = pro.Id;
          
            insert as1;
     
      List<Asset> lsAsset = [select id, Product_Group__c, Product_Collection__c, Product_Category__c from Asset where id IN:assetRecList];
      System.debug('@@lsAsset'+lsAsset);
    
      Integer assetCount= [select count() from Asset where id IN: assetRecList];
      //System.assertEquals(3, assetCount);
      Asset j=assetRecList[0];
       id u=j.id;
    
    
      Issue__c iss=new Issue__c();
      iss.Name='Issuename1';
      iss.Active__c=True;    
      iss.Product_Group__c='Consumer Products';
      iss.Product_Collection__c='3D Printers';
      insert iss;
    
      List<RecordType> i=[Select id,Name from RecordType where Name =:'SalesForce Support'];
      Id k;
   
      RecordType p=i[0];
      k=p.id;
   
    
   //Marwin Change: Validation Rule of Contact_Cannot_Equal_Case_Creator, a case must not have a recordId of 01280000000GFJM"Installation Report"
      Id InstReport = [Select id from RecordType where SobjectType = 'Case' and Name =:'Installation Report' limit 1].id;    
     Case[] CaseList= new List<Case>();
     Integer assetIndex =0;
      for (Integer x=Date.today().addYears(-2).year();x<=Date.today().year();x++) {
            Case cs;
            for (Integer CaseMonth=1; CaseMonth<=12;CaseMonth++){
                cs =new Case();
                cs.RecordTypeId = InstReport ; //change from InstReport to k
                cs.bypassvalidation__c = true;
                cs.Status='Open';
                cs.Description='testdescription';       
                cs.AssetID=assetRecList[assetIndex].Id;
                if((CaseMonth <= Date.today().month() && x==Date.today().year()) || (x < Date.today().year()))
                cs.Install_Completion_Date__c=date.newInstance(x, CaseMonth, 1);
                CaseList.add(cs);
                system.debug('***CaseInstallDate***'+cs.Install_Completion_Date__c);
                assetIndex++;
            }
          
      }
      system.debug('***CaseList***'+CaseList);
      insert CaseList;
    
      Case[] CaseList2= new List<Case>();
    
            for (Integer MonthCounter=1; MonthCounter<=12;MonthCounter++){
                Case cs =new Case();
                cs.RecordTypeId= k ;
                cs.Status='Open';
                cs.Description='testdescription';
                cs.AssetID=assetRecList[MonthCounter-1].Id;
                CaseList2.add(cs);
            }
          
    
      system.debug('***CaseList2***'+CaseList2);
      insert CaseList2;
    
      Case_Issue__c[] CaseIssueList= new List<Case_Issue__c>();
      Integer casecount=0;
      for (Integer y=Date.today().addYears(-2).year();y<=Date.today().year();y++) {
            Case_Issue__c csiss;
            for (Integer MonthCount=1; MonthCount<=12;MonthCount++){
                if((MonthCount <= Date.today().month() && y==Date.today().year()) || (y < Date.today().year())){
                    csiss =new Case_Issue__c();
                    csiss.Case__c = CaseList[casecount].id;
                    csiss.Issue__c= iss.id;
                    csiss.Product_Group__c='Consumer Products';
                    csiss.Product_Collection__c='3D Printers';
                    //Integer installedYear = csiss.asset.InstallDate.year();
                    casecount++;
                    CaseIssueList.add(csiss);
                }
            }
          
      }
      system.debug('***CaseIssueList***'+CaseIssueList);
      insert CaseIssueList;
    
    
      RPU_OOB_Dashboard_Settings__c custSettings = new RPU_OOB_Dashboard_Settings__c();
      custSettings.Name = 'RPUBatchRunTime';
      custSettings.Dashboard_Run_Date__c = system.now();
      custSettings.Status__c = 'Incomplete';
      insert custSettings;
    
    }
  
    public static testmethod void rputest(){
  
  
    test.starttest();
    setup();
    RPUDashboardBatch rs=new RPUDashboardBatch();
    rs.currentDate=date.newInstance(Date.today().year()+1, 1, 1);
    Database.executebatch(rs,200);
    test.stoptest();
  
  
    }
  
    static testMethod void createData(){
    test.starttest();
  
    Account  act = new Account(Name= RPUDashboardBatch.generateRandomString() +'_' +'test', BillingCountryCode='KR');
    insert act;
     Product2 product2_1 = new Product2(
          Name = 'NFR - Freeform Plus',
          CanUseRevenueSchedule = false,
          IsActive = true,
          CurrencyIsoCode = 'USD',
          fw2__Non_Installment__c = false,
          fw2__Recurring__c = false,
          Published__c = true,
          IsFlex__c = true,
          Asset_Tracking__c = false,
          ERP_Taxable_Flag__c = false,
          Servicing_Only__c = false,
          IsEDU__c = false,
          ERP_COMS_NL_TRACKABLE__c = false,
          Asset_Tracking_Override__c = false,
          CPQNewSale__c = false,
          Product_Collection__c ='Geomagic'
        );
        insert product2_1;
    Asset ass = new Asset(Name= RPUDashboardBatch.generateRandomString() +'_' +'test', AccountId=act.id,Product2ID=product2_1.ID);
     insert ass;
     Reseller__c resell2 = new Reseller__c(Name='non-user test',Account__c=act.id);
     insert resell2;
     Opportunity opp = new Opportunity(Name= RPUDashboardBatch.generateRandomString() +'_' +'test-op',AccountID=act.ID,Rapidform_Reseller__c=resell2.ID,StageName='Qualified',CloseDate=Date.today(),FlexNetID__c='12345');
     insert opp;
     test.stoptest();
     }
   }
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CaseTrigger:
execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 02i34000009s1hjAAA;
first error: CANNOT_EXECUTE_FLOW_TRIGGER, We can't save this record because the “Asset Product Categoryv1.4” process failed.
Give your Salesforce admin these details. This error occurred when the flow tried to update records:
LIMIT_EXCEEDED: System.LimitException: Too many SOQL queries: 101. You can look up ExceptionCode values in the SOAP API Developer Guide.: [] Class.CaseTriggerHandler.updateAssetFields: line 261, column 1 Class.CaseTriggerHandler.onAfterUpdate: line 231, column 1 Trigger. 

could you please follow the below code.
 
could you please let me know how can i use line breks in "visualforce email templates" ?
I want to create custom setting for "new case creation after 7 days" in future it may increase to 30 days also and How to refer this custom setting in " Process Builder"?
If a case is closed, and the customer replies to an email, it would automatically re-open case. If past the 7 day mark, if a replies comes it a new case should be created and routed to appropriate queue
List<CaseMilestone> lp_setmstones = new List<CaseMilestone>();
    for (CaseMilestoneSetting__c CMileS : CMileSs){
        id mstoneID = CMileS.MilestoneID__c;
        // Find all CaseMilestones matching our criteria in our caselist
        LIST<CaseMilestone> setmstones;
       
        if(system.test.isRunningTest())
            setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
        else
            setmstones = Database.query('Select ID,MilestoneTypeID,CompletionDate FROM CaseMilestone WHERE '+
                                                        CMileS.CaseCriteria__c+
                                                        'AND CaseID IN:caselist AND MilestoneTypeID=:mstoneID AND CompletionDate=NULL');
                                                       
        // Update the CompletionDate for each CaseMilesone
        for (CaseMilestone updatemstone : setmstones){
            updatemstone.CompletionDate= Datetime.now();
        }
        // Execute the update for all the Milestones in this set
        lp_setmstones.addAll(setmstones);
    }

public Pricebook2 theBook {get;set;}
public List<Authorized_Product__c> authorizedProductObjList =[SELECT Active__c,Distribution_Type__c,Id,Name,Product_Category__c,Product_Collection__c,Price_Book__c,
                                    Product_Family__c,Reseller__c,Standard_Discount__c,Demo_Unit_Discount__c ,Parts_Discount__c,Material_Discount__c
                                    FROM Authorized_Product__c WHERE Reseller__c = :theOpp.RapidForm_Reseller__c AND Active__c = true];
for(Authorized_Product__c authp : authorizedProductObjList){
                
                if(PPP && authp.Product_Family__c.contains('Printers') && authp.Price_Book__c!=null){
                    theBook = [select Id, Name from Pricebook2 where ID = :authp.Price_book__c];
                    forcePricebookSelection=false;
                }
            }
        }