+ Start a Discussion
Akash Garg 2Akash Garg 2 

error of test class while deploying trigger to Production from Sandbox

Akash Garg 
error of test class while deploying trigger to Production from Sandbox
Hello,
I got below error of another apex test class while deploying my trigger and trigger test class to production.
User-added image
My Trigger Test Class i trying to deploy is:-
 
trigger QuoteTriggerInsertQPG on Quote (after insert) {
if(!QuoteInsertFromTriggerHelpper.InsideQuoteInsert){

    
    for(Quote qqq : trigger.new){
    if(qqq.merging__c != true){
   
    map<Id,Quote> QMap = new map<Id,Quote>([select Id, OpportunityId, RecordtypeId,NPD_Required__c, RecordType.developerName from quote 
        where Id IN: trigger.new]);
        List<Quote> quoteId = new List<Quote>();
    Set<String> RecordTypeDevNames = new set<String>();
    set<Id> oppIds = new set<Id>();
    list<Quote_Product_Group__c> QPGlist = new list<Quote_Product_Group__c>();
    list<Quote_Product__c> QPlist = new list<Quote_Product__c>();
    map<Id,Quote_Product_Group__c> QPGmap = new map<Id,Quote_Product_Group__c>();
    
    if(QMap.values()[0].npd_required__c == true){
     
    for(Quote q: QMap.values()){
        RecordTypeDevNames.add(q.RecordType.developerName);
        oppIds.add(q.OpportunityId);
        quoteId.add(q);
    }
    list<recordType> QPRecordTypes = [select Id, DeveloperName from RecordType 
        where sObjectType='Quote_Product__c' and developerName IN: RecordTypeDevNames];
    list<recordType> QPGRecordTypes = [select Id, DeveloperName from RecordType 
        where sObjectType='Quote_Product_Group__c' and developerName IN: RecordTypeDevNames];
    map<Id,Opportunity> Map_oppPG_oppP = new map<Id,Opportunity>([select Id, AccountId, 
        (select id, Account__c,Program_name__c,Quality_reference__c,Opportunity__c,Number_of_Sizes__c,Model__c,
            Fabric_Type__c,Fabric_Design_Type__c,Required_Price_Pc__c,Required_Price_kg__c,Quantity__c,Quantity_UOM__c,
            Packaging_Type_Gross_Level__c,Packaging_Type_Carton_Level__c,Pile_Cotton_Quality_Type__c,Short_Description__c,
            QualityDesign_Type__c,Pile_Yarn_Type__c,Pile_Yarn_Description__c,recordtype.developername from opportunity_product_Groups__r
        ),
        (select id,size_wise_ratio__c,SORTNO_SAP__c,Converted_from_Lead__c,Accessories__c,Private_Label__c,Type_of_pulp__c,npd_flag__c,
            Hanger_Needed__c,Stitch_Type__c,Bartuck_Needed__c, Opportunity_Product_Group__c, Process__c,Count__c,Type__c,
            Other_Spl_Requirment__c,Shade_Reference__c,Required_Price_kg__c,Packing__c,Spl_Requirement__c,
            Raw_Material_3_Per__c,Raw_Material_3__c,Raw_Material_2__c,Raw_Material_2_Per__c,Raw_Material_1__c,Quantity__c,
            End_use__c,Ply__c,Raw_Material__c,Product_form__c,Reel_Width__c,Reel_Width_UOM__c,Sheet_Length__c,
            Sheet_Length_UOM__c,Sheet_Breadth__c,Sheet_Breadth_UOM__c,Ash__c,With_Watermark__c,plant__c,
            No_of_Watermarks_as_per_A3_sheet__c,shade__c,OPacity__c,Cobb_UOM__c,Cobb__c,Whiteness__c,
            Brightness_UOM__c,Brightness__c,GSM_UOM__c,Bulk_CC_gm__c,Quantity_UOM__c,
            Num_of_stitches_1000_size__c,Names_of_Sizes_Bathrobe__c,For__c,Names_of_Sizes__c,Size_Tolerance__c,
            Tolerance_weight__c,Product__c,Test_Protocol__c,Customer_Test_Protocol__c,Needle_Type__c,Pile_Blend__c,
            Sample_Sort__c,Costing_Depth__c,Printed__c,Finish__c,width__c,length__c,size_uom__c,
            Number_of_Colors_Styles__c,Embroidery_Applique__c,Wt_Pc__c,Is_Existing__c,Short_Description__c,
            If_Beach__c,GSM__c,recordtype.developername,SAP_Labdip_Item_No__c,LABDIP_ITEM_SAP__c,T_YARN_COUNT__c, T_YARN_MIXING__c, T_NPD_PRODUCT_TYPE_MY__c, T_YARN_MELANGETYPE__c, T_BLEND_TYPE_NPD__c, T_NPD_DYED_PART__c,T_REAMRK1__c,
            T_YARN_ENDUSE_PLY__c, T_YARN_PLY_COUNT_NPD__c, T_NPD_PLANT__c, Process_Depth_Type__c, T_YRN_PP_SHADE_DEPTH__c, Remark_2__c,Yarn_Product_Type__c
            from opportunity_products__r where Technical_Feasibility__c !='FAILED' and SORTNO_SAP__c != ''
        )
        from Opportunity where Id IN: oppIds]);
    map<String, RecordType> MapQPRecordTypes = new map<String, RecordType>();
    map<String, RecordType> MapQPGRecordTypes = new map<String, RecordType>();
    for(RecordType QPRT : QPRecordTypes){
        if(!MapQPRecordTypes.containsKey(QPRT.developerName)){
            MapQPRecordTypes.put(QPRT.developerName,QPRT);
        }
    }
    for(RecordType QPGRT : QPGRecordTypes){
        if(!MapQPGRecordTypes.containsKey(QPGRT.developerName)){
            MapQPGRecordTypes.put(QPGRT.developerName,QPGRT);
        }
    }
    for(Quote q : trigger.new){
        if(QMap.containsKey(q.Id)){
            String RTdevName = QMap.get(q.id).recordtype.developerName;
            if(RTdevName == 'Bathrobe' || RTdevName == 'Sheeting' || RTdevName == 'Towel' || RTdevName == 'International_Sheeting'){
                if(Map_oppPG_oppP.containsKey(q.OpportunityId)){
                    integer OPG_count = 0;
                    for(opportunity_product_Group__c opg : Map_oppPG_oppP.get(q.OpportunityId).opportunity_product_Groups__r){
                        Quote_Product_Group__c qpg = new Quote_Product_Group__c();
                        if(OPG_count == 0){
                            qpg.Quote__c = q.Id;
                        }else{
                            qpg.Quote__c = QuoteInsertFromTriggerHelpper.CreateQuote(q).Id;
                        }
                        OPG_count++;
                        qpg.Number_of_Sizes__c = opg.Number_of_Sizes__c;
                        qpg.Quality_Reference__c =opg.Quality_Reference__c;
                        qpg.Account__c = opg.Account__c;
                        qpg.Program_name__c = opg.Program_name__c;
                        qpg.Short_Description__c =opg.Short_Description__c ;
                        qpg.Quality_Design_Type__c = opg.QualityDesign_Type__c;
                        qpg.Pile_Yarn_Type__c = opg.Pile_Yarn_Type__c;
                        qpg.Other_Pile_Yarn_Type__c = opg.Pile_Yarn_Description__c;
                        qpg.Pile_Cotton_Quality_Type__c = opg.Pile_Cotton_Quality_Type__c;
                        qpg.Packaging_Type_Carton_Level__c = opg.Packaging_Type_Carton_Level__c;
                        qpg.Packaging_Type_Gross_Level__c = opg.Packaging_Type_Gross_Level__c;
                        qpg.Quantity__c = opg.Quantity__c;
                        qpg.Quantity_UOM__c = opg.Quantity_UOM__c;
                        if(MapQPGRecordTypes.containsKey(RTdevName)){
                            qpg.recordtypeId = MapQPGRecordTypes.get(RTdevName).Id;
                        }
                        if(opg.recordtype.developername == 'Towel'|| opg.recordtype.developername == 'Sheeting'){
                            qpg.Required_Price_Kg__c = opg.Required_Price_Kg__c;
                        }else if(opg.recordtype.developername == 'Bathrobe'){
                            qpg.Model__c = opg.Model__c;
                            qpg.Fabric_type__c = opg.Fabric_Type__c;
                            qpg.Fabric_Design_Type__c = opg.Fabric_Design_Type__c;
                            qpg.Required_Price_Pc__c = opg.Required_Price_Pc__c;
                        }
                        QPGlist.add(qpg);
                        QPGmap.put(opg.Id,qpg);
                        
                    }
                 }
            }
        }
    }
    insert QPGlist;
    for(Quote q : trigger.new){
        if(QMap.containsKey(q.Id)){
            String RTdevName = QMap.get(q.id).recordtype.developerName;
            if(Map_oppPG_oppP.containsKey(q.OpportunityId)){
                for(opportunity_product__c op : Map_oppPG_oppP.get(q.OpportunityId).opportunity_products__r){
                    Quote_Product__c qp= new Quote_Product__c();
                    if(QPGmap.containsKey(op.Opportunity_Product_Group__c)){ 
                        qp.Quote_Product_Group__c = QPGmap.get(op.Opportunity_Product_Group__c).Id;
                        qp.quote__c = QPGmap.get(op.Opportunity_Product_Group__c).quote__c;
                    }
                    else{qp.Quote__c = quoteId[0].id;}
                    qp.Product__c = op.Product__c;
                    qp.Is_Existing__c = op.Is_Existing__c;
                    qp.T_NPD_PLANT__c = op.plant__c;
                    if(MapQPRecordTypes.containsKey(RTdevName)){
                        qp.recordtypeId = MapQPRecordTypes.get(RTdevName).Id;
                    }
                    qp.Short_Description__c =  op.Short_Description__c;
                    if(op.recordtype.developername == 'Towel'|| op.recordtype.developername == 'Sheeting' || op.recordtype.developername == 'Bathrobe'){
                       
                        qp.Is_Converted__c = op.Converted_from_Lead__c;
                        qp.Opp_Product_Id__c = op.id;
                        qp.If_Beach__c = op.If_Beach__c;
                        qp.GSM__c = op.GSM__c;
                        qp.Wt_Pc_gms__c = op.Wt_Pc__c;
                        qp.Embroidery_Applique__c = op.Embroidery_Applique__c;
                        qp.of_Colors_Styles__c =op.Number_of_Colors_Styles__c;
                        qp.Finish__c = op.Finish__c;
                        qp.width__c = op.width__c;
                        qp.length__c =op.length__c;
                        qp.size_uom__c = op.size_uom__c;
                        qp.Printed__c =op.Printed__c;
                        qp.Costing_Depth__c = op.Costing_Depth__c;
                        qp.Quantity_UOM__c=op.Quantity_UOM__c;
                        qp.Sample_Sort_Ref__c = op.Sample_Sort__c;
                        qp.Pile_Blend__c = op.Pile_Blend__c;
                        qp.Needle_Type__c = op.Needle_Type__c;
                        qp.Bartuck_Needed__c = op.Bartuck_Needed__c;
                        qp.Stitch_Type__c = op.Stitch_Type__c;
                        qp.Hanger_Needed__c =op.Hanger_Needed__c;
                        qp.Customer_Test_Protocol__c =op.Customer_Test_Protocol__c;
                        qp.Test_Protocol_Customer__c = op.Test_Protocol__c;
                        qp.Short_Description__c =  op.Short_Description__c;
                        qp.size_wise_ratio__c = op.size_wise_ratio__c;
                        qp.Quantity__c = op.Quantity__c;
                        qp.SAP_Sort_No__c = op.SORTNO_SAP__c;
                        if(!qp.Is_Existing__c &&qp.Product__c ==null){
                            if(qp.GSM__c!=null)
                            {
                            qp.Wt_Pc_gms__c = (qp.GSM__c*(qp.Length__c*qp.Width__c))/1000;
                            }
                            else if(qp.GSM__c== null && qp.Wt_Pc_gms__c !=null)
                            {
                            qp.GSM__c =  (qp.Wt_Pc_gms__c*1000)/(qp.Length__c*qp.Width__c);
                            }
                        }
                    }
                    if(op.recordtype.developername == 'Towel' || op.recordtype.developername == 'Sheeting'){
                        qp.Names_of_Sizes__c = op.Names_of_Sizes__c;
                        qp.Tolerance_weight__c =op.Tolerance_weight__c;
                        qp.Size_Tolerance__c = op.Size_Tolerance__c;
                    }
                    if(op.recordtype.developername == 'Towel'){
                        qp.labdip_flag__c = op.npd_flag__c; 
                    }                   
                    if(op.recordtype.developername == 'Bathrobe'){
                        qp.For__c = op.For__c;
                        qp.Names_of_Sizes__c = op.Names_of_Sizes_Bathrobe__c;
                        qp.Num_of_stitches_1000_size__c =op.Num_of_stitches_1000_size__c;
                        qp.Accessories__c =op.Accessories__c;
                    }else if(op.recordtype.developername == 'Paper'){
                        qp.Is_Converted__c = op.Converted_from_Lead__c;
                        qp.Opp_Product_Id__c = op.id;
                        qp.Quantity__c = op.Quantity__c;
                        qp.Pending_Quantity__c=op.Quantity__c;
                        qp.Quantity_UOM__c=op.Quantity_UOM__c;
                        qp.Bulk_CC_gm__c= op.Bulk_CC_gm__c;
                        qp.GSM__c = op.GSM__c;
                        qp.GSM_UOM__c =op.GSM_UOM__c;
                        qp.Brightness__c = op.Brightness__c;
                        qp.Brightness_UOM__c = op.Brightness_UOM__c;
                        qp.Whiteness__c = op.Whiteness__c ;
                        qp.Cobb__c = op.Cobb__c;
                        qp.Cobb_UOM__c = op.Cobb_UOM__c;
                        qp.OPacity__c =op.OPacity__c;
                        qp.Product_form__c = op.Product_form__c;
                        qp.Reel_Width__c =op.Reel_Width__c;
                        //qp.Reel_Width_UOM__c =op.Reel_Width_UOM__c;
                        qp.Sheet_Length__c =op.Sheet_Length__c;
                        //qp.Sheet_Length_UOM__c =op.Sheet_Length_UOM__c;
                        qp.Sheet_Breadth__c =op.Sheet_Breadth__c ;
                        qp.Size_UOM__c = op.Size_UOM__c;
                        //qp.Sheet_Breadth_UOM__c =op.Sheet_Breadth_UOM__c ;
                        qp.Ash__c = op.Ash__c;
                        qp.With_Watermark__c =op.With_Watermark__c ;
                        qp.No_of_Watermarks_as_per_A3_sheet__c= op.No_of_Watermarks_as_per_A3_sheet__c;
                        qp.shade__c =op.shade__c;
                        qp.Type_of_pulp__c = op.Type_of_pulp__c;
                        qp.Private_Label__c = op.Private_label__c;
                    }else if(op.recordtype.developername == 'Dyed_Yarn'){
                        
                        qp.SAP_Labdip_Recipe__c = op.SAP_Labdip_Item_No__c;
                        qp.SAP_Labdip_Item__c = op.LABDIP_ITEM_SAP__c;
                        qp.labdip_flag__c = op.npd_flag__c;
                        qp.Is_Converted__c = op.Converted_from_Lead__c;
                        qp.Opp_Product_Id__c = op.id;
                        qp.Process__c = op.Process__c;
                        qp.Pending_Quantity__c=op.Quantity__c;
                        qp.Count__c = op.Count__c;
                        qp.Type__c = op.Type__c;
                        qp.End_Use__c = op.End_use__c;
                        qp.Ply__c = op.Ply__c;
                        qp.Raw_Material_1__c = op.Raw_Material__c;
                        qp.Raw_Material_1_per__c = op.Raw_Material_1__c;
                        qp.Raw_Material_2__c =op.Raw_Material_2__c;
                        qp.Raw_Material_2_pre__c= op.Raw_Material_2_Per__c;
                        qp.Raw_Material_3__c = op.Raw_Material_3__c;
                        qp.Raw_Material_3_per__c = op.Raw_Material_3_Per__c;
                        qp.Shade_Reference__c =op.Shade_Reference__c;
                        qp.Required_Price_kg__c = op.Required_Price_kg__c;
                        qp.Quantity__c = op.Quantity__c;
                        qp.Quantity_UOM__c = op.Quantity_UOM__c;
                        qp.Packing__c = op.Packing__c;
                        qp.Spl_Requirement__c = op.Spl_Requirement__c;
                        qp.Other_Spl_Requirement__c = op.Other_Spl_Requirment__c;
                         //added as per Sharad for mapping for Quote PDF
                        qp.Yarn_Cone_Weight__c = ''+op.T_YARN_CONEWEIGHT__c;
                        qp.Yarn_Packaging_Style__c = op.T_YARN_PACKINGSTYLE__c;
                        qp.Yarn_Packaging_Type__c = op.T_YARN_PACKINGTYPE__c;
                        qp.Yarn_Waxing__c = op.T_YARN_WAXING__c;
                        qp.Net_Weight_per_carton__c = op.Net_Weight_per_carton__c;
                        qp.Net_Weight_per_pallet__c = op.Net_Weight_per_pallet__c;
   
                        qp.depth__c = op.Process_Depth_Type__c;

                        
                        
                     }else if(op.recordtype.developername == 'Melange_Yarn'){
                     
                        qp.SAP_Labdip_Recipe__c = op.SAP_Labdip_Item_No__c;
                        qp.SAP_Labdip_Item__c = op.LABDIP_ITEM_SAP__c;
                        qp.labdip_flag__c = op.npd_flag__c;     
                        qp.Opp_Product_Id__c = op.id;                  
                        qp.Is_Converted__c = op.Converted_from_Lead__c;
                        qp.Process__c = op.Process__c;
                        qp.Count__c = op.Count__c;
                        qp.Type__c = op.Type__c;
                        qp.End_Use__c = op.End_use__c;
                        qp.Ply__c = op.Ply__c;
                        qp.Raw_Material_1__c = op.Raw_Material__c;
                        qp.Raw_Material_1_per__c = op.Raw_Material_1__c;
                        qp.Raw_Material_2__c =op.Raw_Material_2__c;
                        qp.Raw_Material_2_pre__c= op.Raw_Material_2_Per__c;
                        qp.Raw_Material_3__c = op.Raw_Material_3__c;
                        qp.Raw_Material_3_per__c = op.Raw_Material_3_Per__c;
                        qp.Shade_Reference__c =op.Shade_Reference__c;
                        qp.Required_Price_kg__c = op.Required_Price_kg__c;
                        qp.Quantity__c = op.Quantity__c;
                        qp.Quantity_UOM__c = op.Quantity_UOM__c;
                        qp.Pending_Quantity__c=op.Quantity__c;
                        qp.Packing__c = op.Packing__c;
                        qp.Spl_Requirement__c = op.Spl_Requirement__c;
                        qp.Other_Spl_Requirement__c = op.Other_Spl_Requirment__c;
                        //added as per Sharad for mapping for Quote PDF
                        qp.Yarn_Cone_Weight__c = ''+op.T_YARN_CONEWEIGHT__c;
                        qp.Yarn_Packaging_Style__c = op.T_YARN_PACKINGSTYLE__c;
                        qp.Yarn_Packaging_Type__c = op.T_YARN_PACKINGTYPE__c;
                        qp.Yarn_Waxing__c = op.T_YARN_WAXING__c;
                        qp.Net_Weight_per_carton__c = op.Net_Weight_per_carton__c;
                        qp.Net_Weight_per_pallet__c = op.Net_Weight_per_pallet__c;
                        
                        //added on 03/10/15
                        qp.T_YARN_COUNT__c = op.T_YARN_COUNT__c;
                        qp.T_YARN_MIXING__c = op.T_YARN_MIXING__c;
                        // ***** Edited due to duplicate mapping (23-03)
                        //qp.T_NPD_PRODUCT_TYPE_MY__c = op.T_NPD_PRODUCT_TYPE_MY__c;                        
                        qp.T_NPD_PRODUCT_TYPE_MY__c = op.Yarn_Product_Type__c;
                        
                        qp.T_YARN_MELANGETYPE__c = op.T_YARN_MELANGETYPE__c;
                        qp.T_BLEND_TYPE_NPD__c = op.T_BLEND_TYPE_NPD__c;
                        qp.T_NPD_DYED_PART__c = op.T_NPD_DYED_PART__c;
                        qp.T_REAMRK1__c = op.T_REAMRK1__c;
                        qp.End_Use__c = op.T_YARN_ENDUSE_PLY__c;
                        qp.T_YARN_PLY_COUNT_NPD__c = op.T_YARN_PLY_COUNT_NPD__c;
                        qp.T_NPD_PLANT__c = op.T_NPD_PLANT__c;
                        qp.Product__c = op.product__c;
                        qp.depth__c = op.Process_Depth_Type__c;
                        qp.depth2__c = op.T_YRN_PP_SHADE_DEPTH__c;
                        qp.shade__c = op.shade__c;
                        qp.Shade_Reference__c = op.Shade_Reference__c;
                        qp.T_REMARK2__c = op.Remark_2__c;
                        
                     }else if(op.recordtype.developername == 'Griege_Yarn'){
                        qp.Is_Converted__c = op.Converted_from_Lead__c;
                        qp.Opp_Product_Id__c = op.id;
                        qp.Process__c = op.Process__c;
                        qp.Count__c = op.Count__c;
                        qp.Type__c = op.Type__c;
                        qp.End_Use__c = op.End_use__c;
                        qp.Ply__c = op.Ply__c;
                        qp.Raw_Material_1__c = op.Raw_Material__c;
                        qp.Raw_Material_1_per__c = op.Raw_Material_1__c;
                        qp.Raw_Material_2__c =op.Raw_Material_2__c;
                        qp.Raw_Material_2_pre__c= op.Raw_Material_2_Per__c;
                        qp.Raw_Material_3__c = op.Raw_Material_3__c;
                        qp.Raw_Material_3_per__c = op.Raw_Material_3_Per__c;
                        qp.Required_Price_kg__c = op.Required_Price_kg__c;
                        qp.Quantity__c = op.Quantity__c;
                        qp.Quantity_UOM__c = op.Quantity_UOM__c;
                        qp.Pending_Quantity__c=op.Quantity__c;
                        qp.Packing__c = op.Packing__c;
                        qp.Spl_Requirement__c = op.Spl_Requirement__c;
                        qp.Other_Spl_Requirement__c = op.Other_Spl_Requirment__c;
                         //added as per Sharad for mapping for Quote PDF
                        qp.Yarn_Cone_Weight__c = ''+op.T_YARN_CONEWEIGHT__c;
                        qp.Yarn_Packaging_Style__c = op.T_YARN_PACKINGSTYLE__c;
                        qp.Yarn_Packaging_Type__c = op.T_YARN_PACKINGTYPE__c;
                        qp.Yarn_Waxing__c = op.T_YARN_WAXING__c;
                        qp.Net_Weight_per_carton__c = op.Net_Weight_per_carton__c;
                        qp.Net_Weight_per_pallet__c = op.Net_Weight_per_pallet__c;
                     }else if(op.recordtype.developername == 'Chemical'){
                        qp.Quantity__c =op.Quantity__c;
                        qp.Opp_Product_Id__c = op.id;
                        qp.Pending_Quantity__c=op.Quantity__c;
                        qp.Quantity_UOM__c=op.Quantity_UOM__c;
                        qp.required_price__c = op.Required_Price_kg__c;
                     }
                     QPList.add(qp);
                 }
             }
         }
     } 
     insert QPList;}

My trigger Test Class i trying to deploy:-
 
@isTest
public class QuoteTriggerInsertQPGTest{
private static testMethod void TriggerInsertQPGTest(){
Account acc = new Account(); 
         acc.Name = 'Test';   
         acc.Total_Purchase_of_Relevant_Products_In__c = 123;   
         acc.Trident_share_in_total_purchase_In_MTs__c = 123; 
         acc.Total_Purchase_of_relevant_products__c = 123;   
         acc.Sales_District__c = 'Z00002-Key Account - India';
         acc.BillingPostalCode='1234';
         acc.ShippingPostalCode='1456';
         acc.BillingState='Delhi';
         acc.ShippingCountry ='India';
         acc.ShippingState ='Goa';
         acc.BillingCountry ='India';
         acc.BillingState='Delhi';
          insert acc;
          
opportunity o = new opportunity();
o.name = 'test';
o.stagename= 'Qualified';
o.closedate = Date.today() + 10;
o.accountid = acc.id;
insert o;
Opportunity_product__c op = new Opportunity_product__c();
op.opportunity__c = o.id;
op.Ash__c = 22;
op.Bartuck_Needed__c = true;
op.T_NPD_ACCESSORIES_COST__c = 56;
op.T_NPD_PACKING_COST__c = 45;
op.T_PRODUCT_SIZE_BATHROBE__c = 'True';
op.Brightness__c = 8;
insert op;
opportunity_product_Group__c opg = new opportunity_product_Group__c();
opg.Number_of_Sizes__c= 2;
opg.opportunity__c = o.id;
insert opg;
Quote q = new Quote();
q.name='Test';
q.opportunityid = o.id;
insert q;
Pcm_sheet__c p = new Pcm_sheet__c();
p.Quote__c = q.id;
insert p;
PCM_LineItem__c pli = new PCM_LineItem__c();
pli.Pcm_sheet__c = p.id;
insert pli;
}
}

Please anyone guide where my error is??
 

 
Akash Garg 2Akash Garg 2
My Another Apex class from where i got error is:-
public with sharing class SelectQuoteController {

    private final Quote q;
        public id selectedValue { get;set; }
        public Id oid,rcdtype;
        public string sobj,rcdtypename;
    public SelectQuoteController (ApexPages.StandardController stdcontroller) {
      this.q = (Quote)stdController.getRecord();
     oid = apexpages.currentpage().getparameters().get('oppid');
     sobj= apexpages.currentpage().getparameters().get('sobject');
     rcdtype=apexpages.currentpage().getparameters().get('recrdtype');
    Opportunity opp = new Opportunity();
     opp = [Select Id,name,Accountid,StageName,probability,account.SAP_Customer_Code__c,Account.ShippingCountry , recordtypeid,Sales_Area__c,Program__c from opportunity where id=:oid ];
     Map<ID, Schema.RecordTypeInfo> rtMap = Schema.SObjectType.opportunity.getRecordTypeInfosById();    //Get record type information            
      if(rtMap.get(opp.recordtypeid )!=Null){
         rcdtypename= rtMap.get(rcdtype).getName();
      }  
    }
    
    public List<selectOption> getQuotes() {
        List<selectOption> options = new List<selectOption>(); //new list for holding all of the picklist options
        options.add(new selectOption('', '- None -')); //add the first option of '- None -' in case the user doesn't want to select a value or in case no values are returned from query below
        for (Quote qtss : [SELECT Id, Name,Quote_Status__c,opportunityid,SAP_QuoteID__c FROM Quote WHERE Quote_Status__c = 'Accepted by Customer' and OpportunityId=:oid]) { //query for Quote records with status Accepted by Customer
          
            options.add(new selectOption(Qtss.Id, Qtss.Name+' - '+ Qtss.SAP_QuoteID__c)); //for all records found - add them to the picklist options
        }
        return options; //return the picklist options
    }
    
   public pagereference next(){
   list<Quote_Product__c> qplist2 = new list<Quote_Product__c>();
   Quote qt=[SELECT Id, Validity_Date__c,Name,Quote_Status__c,opportunityid FROM Quote WHERE Quote_Status__c = 'Accepted by Customer' and OpportunityId=:oid and id=:selectedValue];
    if( rcdtypename=='Towel'){
     List<Quote_Product_Group__c>qpgroup=[Select id ,Quote__c,Quality_Design_Type__c,Pile_Yarn_Type__c,Quantity__c from Quote_Product_Group__c where Quote__c=:qt.id];
     qplist2  = [Select id,EBIDTA__c,Name,Quantity_UOM__c,SAP_Item_No__c,Quote_Product_Group__c,recordtypeid,ply__c,Process__c,Count__c,type__c,gsm__c,names_of_sizes__c,end_use__c,Product_Form__c,Private_Label__c,Packaging_Material__c,Short_Description__c,Product__c,Quantity__c  from Quote_Product__c  where Quote_Product_Group__c in: qpgroup and labdip_flag__c =true and labdip_status__c ='Approved by Customer']; 
   }
   else{
       if( rcdtypename=='Melange Yarn' ||rcdtypename=='Dyed Yarn'){
        qplist2 = [Select id,EBIDTA__c,Quantity_UOM__c,SAP_Item_No__c,Name,Quote_Product_Group__c,ply__c,Process__c,Count__c,type__c,gsm__c,names_of_sizes__c,end_use__c,Product_Form__c,recordtypeid,Short_Description__c,Private_Label__c,Packaging_Material__c,Quote__c,Product__c,Quantity__c  from Quote_Product__c  where Quote__c =: qt.id and labdip_flag__c =true and labdip_status__c ='Approved by Customer'];
                        
       }
   }
   if(qt.Validity_Date__c<system.today()){
   ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.Warning,'Selected Quote is no longer Valid.');
                 ApexPages.addMessage(myMsg);
                 return null;
   }
   if(!qplist2.isempty()){
   if(sobj=='order'){
   
   PageReference neworder = new PageReference('/apex/createorderfromQuoteScreen1?oppid='+oid+'&quoteid='+selectedValue+'&recrdtype='+rcdtype );
                 neworder.setRedirect(true);
                 return neworder; 
   }
   if(sobj=='Contract'){
   PageReference neworder = new PageReference('/apex/tridentCreateContractScreen1?oppid='+oid+'&quoteid='+selectedValue+'&recrdtype='+rcdtype );
                 neworder.setRedirect(true);
                 return neworder; 
   }
   if(sobj=='SchedulingAgreement'){
   PageReference neworder = new PageReference('/apex/trident_scheduling_agreement?oppid='+oid+'&quoteid='+selectedValue+'&recrdtype='+rcdtype );
                 neworder.setRedirect(true);
                 return neworder; 
   }     
   }else{
     ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.Warning,'Quote can not be created as there is no Quote Product whose status is Accepted by Customer');
                 ApexPages.addMessage(myMsg);
                 return null;  
   }   
   return null;
   }
   }
Another Test Class from where i got error is:-
 
@isTest
private class SelectQuoteControllerTEST
{  
 static testMethod void myUnitTest() 
  {
    string rcdtype= Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Dyed Yarn').getRecordTypeId();
    system.debug('================'+rcdtype);
    string rcdtypeo= Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Paper').getRecordTypeId();
    Account a = new Account();
    a.Name = 'Test';   
    a.Total_Purchase_of_Relevant_Products_In__c = 123;   
    a.Trident_share_in_total_purchase_In_MTs__c = 123; 
    a.Total_Purchase_of_relevant_products__c = 123;   
    a.BillingPostalCode = '110011';
    a.Sales_Group__c = 'D08-WEST';
    a.Customer_Account_Group__c = 'Z003-Payer';
    a.ShippingPostalCode = '110100';
    a.BillingCountry ='India';
    a.BillingState ='Goa';
    a.ShippingCountry ='India';
    a.ShippingState ='Goa';
    insert a;
      
    Contact con = new Contact();  
    con.Contact_Status__c =true;     
    con.LastName ='lastname'; 
    con.accountId = a.id; 
    con.Alternate_Phone__c='9807899878';
    insert con; 
    
	opportunity opp = new opportunity();	
    opp.Name = 'Opp'; 
    opp.StageName='Sample test';
    opp.CloseDate= system.Today(); 
    opp.Whiteness__c = 'true';
    opp.accountId = a.id;    
    opp.contact__c =con.id; 
    opp.recordTypeId = rcdtype;
    insert opp;   
    
    Quote q = new Quote(); 
    q.OpportunityId = opp.id;   
    q.name = 'Quote Trident'; 
    q.Quote_Status__c = 'Accepted by Customer';
    q.Validity_Date__c=system.today()+2;
    insert q; 
    
    Quote_Product_Group__c qpg = new Quote_Product_Group__c();
    qpg.quote__c=q.id;
    insert qpg;
    
    Quote_Product__c qp = new Quote_Product__c ();
    qp.Quote__c =q.id;
    qp.labdip_flag__c =true;
    qp.labdip_status__c ='Approved by Customer';
    qp.Quote_Product_Group__c=qpg.id;
    insert qp;
    
	Apexpages.currentpage().getparameters().put('sobject','order');
    Apexpages.currentpage().getparameters().put('oppid',opp.id); 
    Apexpages.currentpage().getparameters().put('recrdtype',opp.recordTypeId);   
    ApexPages.StandardController sc = new ApexPages.standardController(q);
    
	SelectQuoteController slctr= new SelectQuoteController (sc);
    slctr.selectedvalue=q.id;
    slctr.getQuotes();
    slctr.next();
  }
}

Please help in re-solution for the same.
 
Akash Garg 2Akash Garg 2
Can anyone helpme out to find the error??
 
Jane Lee 35Jane Lee 35
I am facing the same issue on this page (http://embroik.com)