• Sujay Kothapalli
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies

Hello gang,

I need your help to write a test class for my after update trigger.

trigger CPQQuotelinesupdate on Summit_CPQ__Quote__c (after update) {
    
    Map < Id, Summit_CPQ__Quote__c > mapQuote = new Map < Id, Summit_CPQ__Quote__c >();
    List < Summit_CPQ__Quote_Line__c > listQuoteLines = new List< Summit_CPQ__Quote_Line__c >();
    
    for ( Summit_CPQ__Quote__c Quote : trigger.new ) {
       
        if(trigger.oldMap.get( Quote.Id ).Summit_CPQ__SubTotal__c != Quote.Summit_CPQ__SubTotal__c || trigger.oldMap.get( Quote.Id ).Solid_Brick_Building_Construction__c != Quote.Solid_Brick_Building_Construction__c || trigger.oldMap.get( Quote.Id ).Travel_Surcharge__c != Quote.Travel_Surcharge__c || trigger.oldMap.get( Quote.Id ).Renovation_Area__c != Quote.Renovation_Area__c)
            
            mapQuote.put( Quote.Id, Quote );
        
        
       if ( mapQuote.size() > 0 ) {
             
  listQuoteLines=[SELECT Summit_CPQ__Product_Code__c,Summit_CPQ__ListPrice__c,Summit_CPQ__Description__c,Summit_CPQ__Unit_Cost__c,Summit_CPQ__Cost_Total__c,Summit_CPQ__Quantity__c,Summit_CPQ__Hide_Line_Item__c, Summit_CPQ__Quote__c FROM Summit_CPQ__Quote_Line__c WHERE Summit_CPQ__Quote__c  IN : mapQuote.keySet()];
 
            for  (Summit_CPQ__Quote_Line__c Quoteline : listQuoteLines)  {
                
                if ((Quoteline.Summit_CPQ__Product_Code__c.contains('SOLIDBRICKSURCHARGE')) && (Quote.Solid_Brick_Building_Construction__c == 'Solid brick')){
                Quoteline.Summit_CPQ__Unit_Cost__c = 50;
                Quoteline.Summit_CPQ__Hide_Line_Item__c = FALSE;
                }
                if ((Quoteline.Summit_CPQ__Product_Code__c.contains('SOLIDBRICKSURCHARGE')) && (Quote.Solid_Brick_Building_Construction__c != 'Solid brick')){
                Quoteline.Summit_CPQ__Unit_Cost__c = 0;
                Quoteline.Summit_CPQ__Hide_Line_Item__c = TRUE;
            }
   update listQuoteLines;
     }
}
}

 

The below is what I've done

@isTest(seealldata=true)
public class CpqQuotelines_Test {
public TestMethod static void CPQQuote_Method()
    {
       
                   
    Summit_CPQ__Quote__c Quote = New Summit_CPQ__Quote__c();
    Quote.Name = 'Test';
    Quote.Solid_Brick_Building_Construction__c = 'Solid brick';
    Quote.Travel_Surcharge__c = 24;
    Quote.Division__c = 'The Inside Project';
    Quote.Renovation_Area__c = 'Ground Floor';
    insert Quote;
    

Id pricebookId = Test.getStandardPricebookId();

//Create your product
Product2 p1 = new Product2(
     Name = 'Product X',
     ProductCode = 'SOLID',
     isActive = true);
     insert p1;
        System.assert(p1.Id != null);
        Product2 p2= new Product2(
        name='TWIG 5',
        IsActive=true,
        ProductCode='CONTINGENCY');
    insert p2;
        System.assert(p2.Id != null);
        
        List<Summit_CPQ__Quote_Line__c> QLList = new List<Summit_CPQ__Quote_Line__c>
    {new Summit_CPQ__Quote_Line__c(Summit_CPQ__Level_Order__c = '1',Summit_CPQ__Hide_Line_Item__c = FALSE,Summit_CPQ__Description__c = 'Not required',
        Summit_CPQ__Quote__c = Quote.id,Summit_CPQ__Quantity__c = 1,Summit_CPQ__Product__c =p1.Id,Summit_CPQ__Unit_Cost__c = 1.00)};
        insert QLList;
       
        
     Summit_CPQ__Quote_Line__c Q2 = New Summit_CPQ__Quote_Line__c();
        Q2.Summit_CPQ__Level_Order__c = '1';
        Q2.Summit_CPQ__Hide_Line_Item__c = TRUE;
        Q2.Summit_CPQ__Description__c = 'required';
        Q2.Summit_CPQ__Quote__c = Quote.id;
        Q2.Summit_CPQ__Quantity__c = 1;
        Q2.Summit_CPQ__Product__c =p2.Id;
        Q2.Summit_CPQ__Unit_Cost__c = 100.00;
        QLList.add(Q2);
      
        
 Summit_CPQ__Quote_Line__c Q3 = New Summit_CPQ__Quote_Line__c();
        Q3.Summit_CPQ__Level_Order__c = '1';
        Q3.Summit_CPQ__Hide_Line_Item__c = TRUE;
        Q3.Summit_CPQ__Description__c = 'required';
        Q3.Summit_CPQ__Quote__c = Quote.id;
        Q3.Summit_CPQ__Quantity__c = 1;
        Q3.Summit_CPQ__Product__c =p2.Id;
        Q3.Summit_CPQ__Unit_Cost__c = 100.00;
        QLList.add(Q3);
      
    List<Summit_CPQ__Quote_Line__c> QLLists = new List<Summit_CPQ__Quote_Line__c>{ [select id,Summit_CPQ__Product_Code__c,Summit_CPQ__ListPrice__c,Summit_CPQ__Description__c,Summit_CPQ__Unit_Cost__c,Summit_CPQ__Cost_Total__c,Summit_CPQ__Quantity__c,Summit_CPQ__Hide_Line_Item__c, Summit_CPQ__Quote__c from Summit_CPQ__Quote_Line__c where id in :QLList and Summit_CPQ__Quote__c = :Quote.Id]};
        for(Summit_CPQ__Quote_Line__c QL1:QLLists){
            If(QL1.Summit_CPQ__Product_Code__c == 'Solid'){
                QL1.Summit_CPQ__Unit_Cost__c= 15;
            }
        }
        
    update QLLists;
        
        Quote.Division__c = 'Wedo';
        update Quote;
       
        }
        
    }

 

Hi,

i've got a invocable method,

global class passbillingid {
   @InvocableMethod
   public static List<String> getBillingIds(List<String> names) {
      List<Id> billingIds = new List<Id>();
      List<AcctSeed__Billing__c> billings = [SELECT Id FROM AcctSeed__Billing__c WHERE Name in :names];
      for (AcctSeed__Billing__c billing : billings) {
         billingIds.add(billing.Id);
      }
      return billingIds;
   }
}

I need to pass this variable into this global class "AcctSeed.BillingPostService.postBillings(billings)"

AcctSeed.PostResult[] postResults = AcctSeed.BillingPostService.postBillings(billings);

How can i do this inthe same invocable method?

Any help is much appreciated.

Cheers,

 

Hi All
I have the folloing trigger and test class, but the test class is not giving me any code coverge
Trigger:
trigger TriggerApprovalcomments on Work_Order__c (before update) {
             List<Work_Order__c> woList =  [Select id,
                                                   (Select Id,
                                                         IsPending,
                                                         ProcessInstanceId,
                                                         TargetObjectId,
                                                         StepStatus,
                                                         OriginalActorId,
                                                         ActorId,
                                                         RemindersSent,
                                                         Comments,
                                                         IsDeleted,
                                                         CreatedDate,
                                                      CreatedById,
                                                         SystemModstamp
                                                   FROM ProcessSteps
                                              ORDER BY CreatedDate DESC)
                                                    From Work_Order__c
                                                WHERE Id IN : Trigger.new];
 
             if(woList.size() > 0){
               for(Work_Order__c wo : woList){
                for(Work_Order__c wo1 : Trigger.new) {
    
                         if(wo.id == wo1.id && wo1.copy_comment__c ) {
                           if (wo.ProcessSteps.size() > 0) {
               
                         wo1.Approver_Comment__c = wo.ProcessSteps[0].Comments;
                         wo1.copy_comment__c = false;
                         }
            
                        }
                 
                    }
               }
             }  
    }

Test Class:
@isTest private class Work_OrderTrigger_Test{
@isTest static void test_Work_OrderTrigger(){
  List<Work_Order__c> wolist= [select id from Work_order__c];
   Work_Order__c wo = new  Work_Order__c ();
        wo.Name = 'Test';
        wo.Type__c = 'Deduction';
        wo.Opportunity__c = '006O0000008sf6u';
        wo.Supplier__c = '001O000001DnolT';
        wo.Family__c = 'Brickwork';
         wolist.add(wo);
    insert wolist;
List<ProcessInstanceStep> processinstancestep_Obj  =  [SELECT Id,ProcessInstanceId,StepStatus,OriginalActorId,ActorId,Comments,StepNodeId,CreatedDate,CreatedById,SystemModstamp from ProcessInstanceStep];  
insert processinstancestep_obj;
   
              if(woList.size() > 0){
                           if (wo.ProcessSteps.size() > 0) {
               
                         wo.Approver_Comment__c = wo.ProcessSteps[0].Comments;
                         wo.copy_comment__c = false;
                           }}}}
Please help me 
Thank you
 
Hi All,
I have a requirement to get approval comments for reporting purposes.
I have created a custom long text field, this field needs to be updated with approval comments
I'm fairly new to coding, i have tried using flow but didn't get results.
Any help is much appreciated
Hi,
i am creating a new formula field with date data type.
Planned_Start_Date__c  -  Start_Date__c
Both are date fields. 
Still getting an error!!

 

Hi,

i've got a invocable method,

global class passbillingid {
   @InvocableMethod
   public static List<String> getBillingIds(List<String> names) {
      List<Id> billingIds = new List<Id>();
      List<AcctSeed__Billing__c> billings = [SELECT Id FROM AcctSeed__Billing__c WHERE Name in :names];
      for (AcctSeed__Billing__c billing : billings) {
         billingIds.add(billing.Id);
      }
      return billingIds;
   }
}

I need to pass this variable into this global class "AcctSeed.BillingPostService.postBillings(billings)"

AcctSeed.PostResult[] postResults = AcctSeed.BillingPostService.postBillings(billings);

How can i do this inthe same invocable method?

Any help is much appreciated.

Cheers,

 

Hello gang,

I need your help to write a test class for my after update trigger.

trigger CPQQuotelinesupdate on Summit_CPQ__Quote__c (after update) {
    
    Map < Id, Summit_CPQ__Quote__c > mapQuote = new Map < Id, Summit_CPQ__Quote__c >();
    List < Summit_CPQ__Quote_Line__c > listQuoteLines = new List< Summit_CPQ__Quote_Line__c >();
    
    for ( Summit_CPQ__Quote__c Quote : trigger.new ) {
       
        if(trigger.oldMap.get( Quote.Id ).Summit_CPQ__SubTotal__c != Quote.Summit_CPQ__SubTotal__c || trigger.oldMap.get( Quote.Id ).Solid_Brick_Building_Construction__c != Quote.Solid_Brick_Building_Construction__c || trigger.oldMap.get( Quote.Id ).Travel_Surcharge__c != Quote.Travel_Surcharge__c || trigger.oldMap.get( Quote.Id ).Renovation_Area__c != Quote.Renovation_Area__c)
            
            mapQuote.put( Quote.Id, Quote );
        
        
       if ( mapQuote.size() > 0 ) {
             
  listQuoteLines=[SELECT Summit_CPQ__Product_Code__c,Summit_CPQ__ListPrice__c,Summit_CPQ__Description__c,Summit_CPQ__Unit_Cost__c,Summit_CPQ__Cost_Total__c,Summit_CPQ__Quantity__c,Summit_CPQ__Hide_Line_Item__c, Summit_CPQ__Quote__c FROM Summit_CPQ__Quote_Line__c WHERE Summit_CPQ__Quote__c  IN : mapQuote.keySet()];
 
            for  (Summit_CPQ__Quote_Line__c Quoteline : listQuoteLines)  {
                
                if ((Quoteline.Summit_CPQ__Product_Code__c.contains('SOLIDBRICKSURCHARGE')) && (Quote.Solid_Brick_Building_Construction__c == 'Solid brick')){
                Quoteline.Summit_CPQ__Unit_Cost__c = 50;
                Quoteline.Summit_CPQ__Hide_Line_Item__c = FALSE;
                }
                if ((Quoteline.Summit_CPQ__Product_Code__c.contains('SOLIDBRICKSURCHARGE')) && (Quote.Solid_Brick_Building_Construction__c != 'Solid brick')){
                Quoteline.Summit_CPQ__Unit_Cost__c = 0;
                Quoteline.Summit_CPQ__Hide_Line_Item__c = TRUE;
            }
   update listQuoteLines;
     }
}
}

 

The below is what I've done

@isTest(seealldata=true)
public class CpqQuotelines_Test {
public TestMethod static void CPQQuote_Method()
    {
       
                   
    Summit_CPQ__Quote__c Quote = New Summit_CPQ__Quote__c();
    Quote.Name = 'Test';
    Quote.Solid_Brick_Building_Construction__c = 'Solid brick';
    Quote.Travel_Surcharge__c = 24;
    Quote.Division__c = 'The Inside Project';
    Quote.Renovation_Area__c = 'Ground Floor';
    insert Quote;
    

Id pricebookId = Test.getStandardPricebookId();

//Create your product
Product2 p1 = new Product2(
     Name = 'Product X',
     ProductCode = 'SOLID',
     isActive = true);
     insert p1;
        System.assert(p1.Id != null);
        Product2 p2= new Product2(
        name='TWIG 5',
        IsActive=true,
        ProductCode='CONTINGENCY');
    insert p2;
        System.assert(p2.Id != null);
        
        List<Summit_CPQ__Quote_Line__c> QLList = new List<Summit_CPQ__Quote_Line__c>
    {new Summit_CPQ__Quote_Line__c(Summit_CPQ__Level_Order__c = '1',Summit_CPQ__Hide_Line_Item__c = FALSE,Summit_CPQ__Description__c = 'Not required',
        Summit_CPQ__Quote__c = Quote.id,Summit_CPQ__Quantity__c = 1,Summit_CPQ__Product__c =p1.Id,Summit_CPQ__Unit_Cost__c = 1.00)};
        insert QLList;
       
        
     Summit_CPQ__Quote_Line__c Q2 = New Summit_CPQ__Quote_Line__c();
        Q2.Summit_CPQ__Level_Order__c = '1';
        Q2.Summit_CPQ__Hide_Line_Item__c = TRUE;
        Q2.Summit_CPQ__Description__c = 'required';
        Q2.Summit_CPQ__Quote__c = Quote.id;
        Q2.Summit_CPQ__Quantity__c = 1;
        Q2.Summit_CPQ__Product__c =p2.Id;
        Q2.Summit_CPQ__Unit_Cost__c = 100.00;
        QLList.add(Q2);
      
        
 Summit_CPQ__Quote_Line__c Q3 = New Summit_CPQ__Quote_Line__c();
        Q3.Summit_CPQ__Level_Order__c = '1';
        Q3.Summit_CPQ__Hide_Line_Item__c = TRUE;
        Q3.Summit_CPQ__Description__c = 'required';
        Q3.Summit_CPQ__Quote__c = Quote.id;
        Q3.Summit_CPQ__Quantity__c = 1;
        Q3.Summit_CPQ__Product__c =p2.Id;
        Q3.Summit_CPQ__Unit_Cost__c = 100.00;
        QLList.add(Q3);
      
    List<Summit_CPQ__Quote_Line__c> QLLists = new List<Summit_CPQ__Quote_Line__c>{ [select id,Summit_CPQ__Product_Code__c,Summit_CPQ__ListPrice__c,Summit_CPQ__Description__c,Summit_CPQ__Unit_Cost__c,Summit_CPQ__Cost_Total__c,Summit_CPQ__Quantity__c,Summit_CPQ__Hide_Line_Item__c, Summit_CPQ__Quote__c from Summit_CPQ__Quote_Line__c where id in :QLList and Summit_CPQ__Quote__c = :Quote.Id]};
        for(Summit_CPQ__Quote_Line__c QL1:QLLists){
            If(QL1.Summit_CPQ__Product_Code__c == 'Solid'){
                QL1.Summit_CPQ__Unit_Cost__c= 15;
            }
        }
        
    update QLLists;
        
        Quote.Division__c = 'Wedo';
        update Quote;
       
        }
        
    }

 

Hi,

i've got a invocable method,

global class passbillingid {
   @InvocableMethod
   public static List<String> getBillingIds(List<String> names) {
      List<Id> billingIds = new List<Id>();
      List<AcctSeed__Billing__c> billings = [SELECT Id FROM AcctSeed__Billing__c WHERE Name in :names];
      for (AcctSeed__Billing__c billing : billings) {
         billingIds.add(billing.Id);
      }
      return billingIds;
   }
}

I need to pass this variable into this global class "AcctSeed.BillingPostService.postBillings(billings)"

AcctSeed.PostResult[] postResults = AcctSeed.BillingPostService.postBillings(billings);

How can i do this inthe same invocable method?

Any help is much appreciated.

Cheers,