• Chaim Rosenfeld 8
  • NEWBIE
  • 20 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies
   Hello, can anyone help me in this question, in this method i am some custom record as well as attachment, my test class is running for custom records but it gives error "System.DmlException: Upsert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Body]: [Body]"

this is method's code , 

Public PageReference saveRecordlprop(){
lead.Labor_Mid_Construction_Proposal_Added__c = true ;
upsert lead;
update testlprop ; 
lprop.Marketing_Material__c = testlprop.Marketing_Material__c;
lprop.Holiday_Coverage__c = testlprop.Holiday_Coverage__c;
lprop.Management_and_Supervision__c = testlprop.Management_and_Supervision__c ;
lprop.Over_Time_Hours__c = testlprop.Over_Time_Hours__c ;
lprop.Payment_Terms__c = testlprop.Payment_Terms__c ;
lprop.Pricing__c = testlprop.Pricing__c ;
lprop.Statement_of_Work__c = testlprop.Statement_of_Work__c  ;
lprop.Supplies_and_Equipment__c = testlprop.Supplies_and_Equipment__c ;
lprop.Contract_Terms__c = testlprop.Contract_Terms__c;
insert lprop;
    
lpdocument = new Attachment();
lpdocument.Name = 'Client cover image';
lpdocument.ParentId = lprop.ID;
lpdocument.Body = lpfileBody;
upsert lpdocument;

lprop.Current_Record_ID__c = lpdocument.ID;

upsert lprop; 
    PageReference p = new PageReference('/' + this.lprop.Id );
    return p;
}

and this is my test class for this controller 

@isTest 
public class addProposalCntrltest2{

static testMethod void testMethod1() {

        Lead testRecord= new Lead();
        
        testRecord.LastName = 'test name ';
        testRecord.Company = 'test company';
        testRecord.Status = 'new';
        testRecord.Credit_Limit_Amount__c = 12344;
        

        insert testRecord;
        
        Laborer_Mid_Construction_Proposal__c testRecord2 = new Laborer_Mid_Construction_Proposal__c();
        testRecord2.Name = 'test';
        testRecord2.Lead__c= testRecord.ID;

        insert testRecord2 ;
        
    
        Blob lpfileBody  = Blob.valueOf('Test Data');
          Attachment attachment = new Attachment();
        attachment.Name = 'Test Attachment for Parent';
        attachment.ParentId = testRecord2.ID;
        attachment.Body = lpfileBody;
        
        insert attachment;
    
    
        Steady_Maintenance_Proposal__c testRecord3 = new Steady_Maintenance_Proposal__c();
        testRecord3.Name = 'test';
        testRecord3.Lead__c= testRecord.ID;

        insert testRecord3;
        
        Post_Construction_Cleanup_Proposal__c testRecord4 = new Post_Construction_Cleanup_Proposal__c();
         testRecord4.Name = 'test';
         testRecord4.Lead__c= testRecord.ID;

         insert testRecord4 ;
         
        Steady_Maintenance_Commercial__c testRecord5 = new Steady_Maintenance_Commercial__c();
        testRecord5.Name = 'test';
        testRecord5.Lead__c= testRecord.ID;

        Insert testRecord5;
        
        Steady_Maintenance_Residential__c testRecord6 = new Steady_Maintenance_Residential__c();
         testRecord6.Name = 'test';
         testRecord6.Lead__c= testRecord.ID;

         insert testRecord6 ;
         
         Floor_Cleaning_Project_Over_View__c  testRecord7 = new Floor_Cleaning_Project_Over_View__c();
         testRecord7.Name = 'test';
         testRecord7.Lead__c= testRecord.ID;

         insert testRecord7;
          
         General_PCC_Project_Over_View__c testRecord8 = new General_PCC_Project_Over_View__c();
         testRecord8.Name = 'test';
         testRecord8.Lead__c= testRecord.ID;

         insert testRecord8;
         
         Window_Cleaning_Project_Overview__c testRecord9 = new Window_Cleaning_Project_Overview__c();
         testRecord9.Name = 'test';
         testRecord9.Lead__c= testRecord.ID;

         insert testRecord9 ;
          



        Test.setCurrentPage(Page.addProposal);
        System.currentPageReference().getParameters().put('id', testRecord.Id);
        
        



        addProposalCntrl addProposalCntrlTestIns = new addProposalCntrl();
        
        addProposalCntrlTestIns.saveRecordlprop();
        addProposalCntrlTestIns.saveRecordspropComm();
        addProposalCntrlTestIns.saveRecordspropResd();
        addProposalCntrlTestIns.saveRecordpprop1();
        addProposalCntrlTestIns.saveRecordpprop2();
        addProposalCntrlTestIns.saveRecordpprop3();
        

        
    }
    private static void addAttachmentToParent(Id testRecord) {
        
    }
 }

Thank you!
    
Hello , 

i have two objects, 
1.Steady_Maintenance_Proposal__c
2.Steady_Maintenance_Commercial__c

both of these objects have Scope of work Rich Text area Fields, i want when ever Steady_Maintenance_Commercial__c object's rich text area field get created, it should automatically update the Steady_Maintenance_Proposal__c objects Scope of work, 
I have already tried work flow rule and process builder, both of these get saved with now errors, but dont update fields, 

i have added look up field of Steady_Maintenance_Commercial__c  on Steady_Maintenance_Proposal__c object ,

Please help me in this if any one has already came across this problem 


 
Hello , i need help in test class of this visualforce page and controller, 

<apex:page controller="addJobCntrl"  sidebar="false" showHeader="false" >
<style>
.picklist{
 border:none;
 background-color : #ECECEC;
  width: 100%;
  padding: 12px 20px;

}
.picklist2{
 border:none;
 background-color : #ECECEC;
  width: 100%;
  padding: 12px 20px;

}

.lbl{
text-align:left;
font-family:Arial;
font-size:15px;
font-weight:bold;


}
.inp1 {
     border:none;
     background-color : #ECECEC;
     padding: 12px  30px;
     font-family:Arial;


  
}
.btn{

background-color: #4CAF50; /* Green */
    border: none;
    color: white;
    padding: 8px 20px;
    text-align: center;
    text-decoration: none ;
    display: inline-block;
    font-size: 16px;



}

</style>
<apex:form >
<div align="center">
<apex:outputLabel value="Please choose Customer from below list and Click Create Job Button" styleClass="lbl" ></apex:outputLabel>
<br/>
<br/>
<apex:inputField value="{!jobIns.Customer__c}" label="" id="Customer"/>
<br/>
<apex:commandButton action="{!creatContract}"  value="Create Job" styleClass="btn"/>  
</div>
</apex:form>  
  
  
</apex:page>

This is its Controller 

public class addJobCntrl {

Public string leadID{get;set;}
Public Lead leadIns{get;set;}
Public Job__c jobIns{get;set;}


public addJobCntrl (){

leadID = apexpages.currentpage().getparameters().get('id');
leadIns= [select id, Company, State__c, Street__c , Zip__c , City__c , Type_of_Service_Proposal__c , Name  , Sales_Person__c, Insurance_Amount__c , Email, Credit_Application_received__c, Credit_Limit_Amount__c,  Phone from Lead where ID =: leadID ];
jobIns = new Job__c(Lead__c  = leadID );


}


Public PageReference creatContract(){


jobIns.Name = leadIns.Company;
jobIns.Sales_Rep__c = leadIns.Sales_Person__c;
jobIns.Billing_Contact__c = leadIns.Name  ;
jobIns.Billing_Email__c = leadIns.Email;
jobIns.Billing_Phone_Number__c =  leadIns.Phone;
jobIns.Street__c = leadIns.Street__c ;
jobIns.State__c = leadIns.State__c ;
jobIns.Zipcode__c = leadIns.Zip__c ;
jobIns.City__c = leadIns.City__c ;
jobIns.Service_Type__c = leadIns.Type_of_Service_Proposal__c ;
jobIns.Credit_Application_received__c = leadIns.Credit_Application_received__c;
jobIns.Credit_Amount_Limit__c = leadIns.Credit_Limit_Amount__c;
jobIns.Insurance_Amount__c = leadIns.Insurance_Amount__c;

upsert jobIns;



PageReference p = new PageReference('/' + this.jobIns.Id );
return p;
}
}


and this is its test class 

@isTest 
public class addJobCntrlTest{

static testMethod void testMethod1() {
       Account custIns = new Account();
       custIns.Name = 'test';
       custIns.QB_Company__c = 'qfs';
       custIns.QB_Account__c = 'test'; 
       custIns.Service_Type__c  = 'Mid-Construction';
       insert custIns;
       
       Job__c jobIns = new Job__c();
       jobIns.Name = 'test';
       jobIns.Sales_Rep__c = 'Aharon Kaplan';
       jobIns.Customer__c = custIns.ID;
       jobIns.Billing_Contact__c = 'test';  
       jobIns.Billing_Email__c= 'test@test.com'; 
       jobIns.Billing_Phone_Number__c= '123'; 
       jobIns.QB_Job_Name__c = 'test';   
       jobIns.QB_Company__c = 'QFS';
       
       insert jobIns;
       
       
        
       Lead testRecord= new Lead();
       testRecord.LastName = 'test name ';
       testRecord.Company = 'test company';
       testRecord.Status = 'new';
       testRecord.Credit_Limit_Amount__c = 12344;
       insert testRecord;
     

        Test.setCurrentPage(Page.addJob);
        System.currentPageReference().getParameters().put('id', testRecord.Id);

        addJobCntrl addjobCntrlTestIns = new addJobCntrl();
        
        addjobCntrlTestIns.creatContract();
    }
 }

this test class is giving this error. 

System.DmlException: Upsert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Customer__c]: [Customer__c]

I am not sure why i keep getting this error, i am getting customer__c value from visualforce page's input field from user, visualforce page is giving / creating correct records, but in test class it says customer__c value is required , 

can any one pleaes help me in this at your earliest possible ???? 
hello , my test class for this controller is giving 88% coverage, but it is not being deployed , can any one help me in this


public class addJobCntrl {

Public string leadID{get;set;}
Public Lead leadIns{get;set;}
Public Job__c jobIns{get;set;}
Public Job__c testjobIns{get;set;}


public addJobCntrl (){

leadID = apexpages.currentpage().getparameters().get('id');
leadIns= [select id, Company, State__c, Street__c , Zip__c , City__c , Type_of_Service_Proposal__c , Name  , Sales_Person__c, Insurance_Amount__c , Email, Credit_Application_received__c, Credit_Limit_Amount__c,  Phone from Lead where ID =: leadID ];
jobIns = new Job__c(Lead__c = leadID );


}


Public PageReference creatContract(){


jobIns.Name = leadIns.Company;
jobIns.Street__c = leadIns.Street__c ;
jobIns.State__c = leadIns.State__c ;
jobIns.Zipcode__c = leadIns.Zip__c ;
jobIns.City__c = leadIns.City__c ;
jobIns.Service_Type__c = leadIns.Type_of_Service_Proposal__c ;
jobIns.Billing_Contact__c = leadIns.Name  ;
jobIns.Billing_Email__c = leadIns.Email;
jobIns.Billing_Phone_Number__c =  leadIns.Phone;
jobIns.Credit_Application_received__c = leadIns.Credit_Application_received__c;
jobIns.Credit_Amount_Limit__c = leadIns.Credit_Limit_Amount__c;
jobIns.Insurance_Amount__c = leadIns.Insurance_Amount__c;
jobIns.Sales_Rep__c = leadIns.Sales_Person__c;

upsert jobIns;


PageReference p = new PageReference('/' + this.jobIns.Id );
return p;
}
}


this is Test class 

@isTest 
public class addJobCntrlTest{

static testMethod void testMethod1() {
       Account custIns = new Account();
       custIns.Name = 'test';
       custIns.QB_Company__c = 'qfs';
       custIns.QB_Account__c = 'test'; 
       custIns.Service_Type__c  = 'Mid-Construction';
       insert custIns;
       
       Job__c jobIns = new Job__c();
       jobIns.Name = 'test';
       jobIns.Sales_Rep__c = 'Aharon Kaplan';
       jobIns.Customer__c = custIns.ID;
       jobIns.Billing_Contact__c = 'test';  
       jobIns.Billing_Email__c= 'test@test.com'; 
       jobIns.Billing_Phone_Number__c= '123'; 
       jobIns.QB_Job_Name__c = 'test';   
       jobIns.QB_Company__c = 'QFS';
       
       insert jobIns;
       
       
        
       Lead testRecord= new Lead();
       testRecord.LastName = 'test name ';
       testRecord.Company = 'test company';
       testRecord.Status = 'new';
       testRecord.Credit_Limit_Amount__c = 12344;
       insert testRecord;
     

        Test.setCurrentPage(Page.addJob);
        System.currentPageReference().getParameters().put('id', testRecord.Id);

        addJobCntrl addjobCntrlTestIns = new addJobCntrl();
        
        addjobCntrlTestIns.creatContract();
    }
 }


and this is error i keep getting from test run 

upsert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Customer__c]: 

 
hello , i am not being able to run my test class for this controller , 

public class addLaborProposalCntrl {
    Public string leadID{get;set;}
    Public string testlpropID{get;set;}
    Public Lead lead {get;set;}
    Public Laborer_Mid_Construction_Proposal__c lprop {get;set;}
    Public Laborer_Mid_Construction_Proposal__c testlprop {get;set;}

    
    public addLaborProposalCntrl () {                  
    testlprop = [SELECT Marketing_Material__c, Holiday_Coverage__c,Management_and_Supervision__c, Over_Time_Hours__c, Pricing__c , Payment_Terms__c,Statement_of_Work__c,Supplies_and_Equipment__c FROM Laborer_Mid_Construction_Proposal__c where Name LIKE 'Test%' Limit 1 ];
    leadID = apexpages.currentpage().getparameters().get('id');
    lead = new Lead(ID = leadID);
    lprop = new Laborer_Mid_Construction_Proposal__c(Lead__c = LeadID );
    
    }
Public PageReference saveRecordlprop(){
upsert lead;
update testlprop ; 
lprop.Marketing_Material__c = testlprop.Marketing_Material__c;
lprop.Holiday_Coverage__c = testlprop.Holiday_Coverage__c;
lprop.Management_and_Supervision__c = testlprop.Management_and_Supervision__c ;
lprop.Over_Time_Hours__c = testlprop.Over_Time_Hours__c ;
lprop.Payment_Terms__c = testlprop.Payment_Terms__c ;
lprop.Pricing__c = testlprop.Pricing__c ;
lprop.Statement_of_Work__c = testlprop.Statement_of_Work__c  ;
lprop.Supplies_and_Equipment__c = testlprop.Supplies_and_Equipment__c ;
upsert lprop;  
    PageReference p = new PageReference('/' + this.lprop.Id );
    return p;
}


}

this is my Test Class 

@isTest 
public class addLaborProposalCntrlTest{

static testMethod void testMethod1() {

        Lead testRecord= new Lead();
        
        testRecord.LastName = 'test name ';
        testRecord.Company = 'test company';
        testRecord.Status = 'new';
        testRecord.Credit_Limit_Amount__c = 12344;
        insert testRecord;

        Laborer_Mid_Construction_Proposal__c testRecord2 = new Laborer_Mid_Construction_Proposal__c();
        testRecord2.Lead__C = testRecord.ID;
        testRecord2.Marketing_Material__c = 'test';
        testRecord2.Holiday_Coverage__c = 'test';
        testRecord2.Management_and_Supervision__c = 'test';
        testRecord2.Over_Time_Hours__c = 'test';
        testRecord2.Payment_Terms__c = 'test';
        testRecord2.Pricing__c = 'test';
        testRecord2.Statement_of_Work__c = 'test';
        testRecord2.Supplies_and_Equipment__c = 'test';
        
        
        testRecord2.Name = 'test';
        insert testRecord2;
        
        update testRecord2;
        


        Test.setCurrentPage(Page.addJob);
        System.currentPageReference().getParameters().put('id', testRecord2.Id);
        
        addLaborProposalCntrl addjobCntrlTestIns = new addLaborProposalCntrl();
        
        addjobCntrlTestIns.saveRecordlprop();
    }
 }

it gives this error 

System.TypeException: Invalid id value for this SObject type: a091g0000085HO8AAM error 

can anyone please help me in this 
 
Hello guys, can any one please help me creating test class which include multiple methods, 
my controller code is as 

public class addProposalCntrl {



   


    Public string leadID{get;set;}
    Public string testlpropID{get;set;}
    Public string testppropID{get;set;}
    Public string testspropID{get;set;}
    Public string testcommID{get;set;}
    Public string testresdID{get;set;}
    Public Lead lead {get;set;}
    
    Public string floorPOID{get;set;}
    Public string generalpccPOID{get;set;}
    Public string windowPOID{get;set;}

    
    Public Laborer_Mid_Construction_Proposal__c lprop {get;set;}
    Public Laborer_Mid_Construction_Proposal__c testlprop {get;set;}
    Public Laborer_Mid_Construction_Proposal__c lpropIns {get;set;}
    Public Steady_Maintenance_Proposal__c sprop {get;set;}
    Public Steady_Maintenance_Proposal__c testsprop {get;set;}
    Public Post_Construction_Cleanup_Proposal__c pprop {get;set;}
    Public Post_Construction_Cleanup_Proposal__c testpprop {get;set;}
    Public Steady_Maintenance_Commercial__c steadyComm{get;set;}
    Public Steady_Maintenance_Commercial__c teststeadyComm{get;set;}
    Public Steady_Maintenance_Residential__c steadyResd{get;set;}
    Public Steady_Maintenance_Residential__c teststeadyResd{get;set;}
    
    Public Floor_Cleaning_Project_Over_View__c  floorPO{get;set;}
    Public Floor_Cleaning_Project_Over_View__c  testfloorPO{get;set;}
    Public General_PCC_Project_Over_View__c generalpccPO{get;set;}
    Public General_PCC_Project_Over_View__c testgeneralpccPO{get;set;}
    Public Window_Cleaning_Project_Overview__c windowPO{get;set;}
    Public Window_Cleaning_Project_Overview__c testwindowPO{get;set;}







    


    public addProposalCntrl () {    
    
    testlpropID= 'a091g000004naaqAAA';
    testppropID = 'a0B1g0000033u90EAA';
    testspropID = 'a0A1g000000RlDZEA0';
    testcommID = 'a0C1g000000saTmEAI';
    testresdID = 'a0D1g000002274aEAA';
    floorPOID = 'a0b1g000001CBfXAAW';
    generalpccPOID = 'a0c1g000000UGEgAAO';
    windowPOID = 'a0a1g00000192O3AAI';
    
    
    testlprop = [SELECT Marketing_Material__c, Holiday_Coverage__c,Management_and_Supervision__c, Over_Time_Hours__c, Pricing__c , Payment_Terms__c,Statement_of_Work__c,Supplies_and_Equipment__c FROM Laborer_Mid_Construction_Proposal__c where ID =: testlpropID];
    testpprop = [SELECT Contract_Terms__c, Pricing_and_Agreement__c FROM  Post_Construction_Cleanup_Proposal__c where ID =: testppropID];
    testsprop = [SELECT Extraordinary_Maintenance_Requirements__c,Holiday_Coverage__c, Payment_Terms__c , Pricing__c, Sick_Pay__c, Supplies_and_Equipment__c  , Uniform__c , Marketing_Material__c FROM  Steady_Maintenance_Proposal__c where ID =: testspropID];
    teststeadyComm = [SELECT id, Scope_of_Work__c from Steady_Maintenance_Commercial__c  where id =: testcommID ];
    teststeadyResd = [SELECT id, Scope_of_Work__c from Steady_Maintenance_Residential__c where id =: testresdID ];
    testfloorPO = [select id, Project_Overview__c   from Floor_Cleaning_Project_Over_View__c  where id =: floorPOID ];
    testgeneralpccPO = [select id, Project_Overview__c  from General_PCC_Project_Over_View__c  where id =: generalpccPOID ];
    testwindowPO = [select id, Project_Overview__c  from Window_Cleaning_Project_Overview__c where id =: windowPOID  ];

    leadID = apexpages.currentpage().getparameters().get('id');
    lead = new Lead(ID = leadID);
    pprop = new Post_Construction_Cleanup_Proposal__c(Lead__c = LeadID);
    sprop  = new Steady_Maintenance_Proposal__c(Lead__c = LeadID);
    lprop = new Laborer_Mid_Construction_Proposal__c (Lead__c = LeadID );
    steadyComm = new Steady_Maintenance_Commercial__c (Lead__c = leadID);
    steadyResd = new Steady_Maintenance_Residential__c (Lead__c = leadID);  
    floorPO = new Floor_Cleaning_Project_Over_View__c (Lead__c = leadID);
    generalpccPO = new General_PCC_Project_Over_View__c (Lead__c = leadID);
    windowPO = new Window_Cleaning_Project_Overview__c (Lead__c = leadID);
    
    }
    
    

Public PageReference saveRecordlprop(){

upsert lead;
update testlprop ; 
lprop.Marketing_Material__c = testlprop.Marketing_Material__c;
lprop.Holiday_Coverage__c = testlprop.Holiday_Coverage__c;
lprop.Management_and_Supervision__c = testlprop.Management_and_Supervision__c ;
lprop.Over_Time_Hours__c = testlprop.Over_Time_Hours__c ;
lprop.Payment_Terms__c = testlprop.Payment_Terms__c ;
lprop.Pricing__c = testlprop.Pricing__c ;
lprop.Statement_of_Work__c = testlprop.Statement_of_Work__c  ;
lprop.Supplies_and_Equipment__c = testlprop.Supplies_and_Equipment__c ;


 insert lprop;
    
   
    
    PageReference p = new PageReference('/' + this.lprop.Id );
    return p;
}

Public PageReference saveRecordspropComm(){
    upsert lead;
    update testsprop;
    sprop.Marketing_Material__c = testsprop.Marketing_Material__c;
    sprop.Extraordinary_Maintenance_Requirements__c = testsprop.Extraordinary_Maintenance_Requirements__c;
    sprop.Holiday_Coverage__c = testsprop.Holiday_Coverage__c;
    sprop.Payment_Terms__c = testsprop.Payment_Terms__c;  
    sprop.Pricing__c = testsprop.Pricing__c;  
    sprop.Sick_Pay__c = testsprop.Sick_Pay__c;  
    sprop.Supplies_and_Equipment__c  = testsprop.Supplies_and_Equipment__c  ;  
    sprop.Uniform__c = testsprop.Uniform__c;  
    update teststeadyComm ;
    steadyComm.Scope_of_Work__c = teststeadyComm.Scope_of_Work__c ;
    
    
    upsert steadyComm;
    

    upsert sprop;
    PageReference p = new PageReference('/' + this.sprop.Id );
    return p;
}

Public PageReference saveRecordspropResd(){
    upsert lead;
    update testsprop;
    sprop.Marketing_Material__c= testsprop.Marketing_Material__c;
    sprop.Extraordinary_Maintenance_Requirements__c = testsprop.Extraordinary_Maintenance_Requirements__c;  
    sprop.Holiday_Coverage__c = testsprop.Holiday_Coverage__c;
    sprop.Payment_Terms__c = testsprop.Payment_Terms__c;  
    sprop.Pricing__c = testsprop.Pricing__c;  
    sprop.Sick_Pay__c = testsprop.Sick_Pay__c;  
    sprop.Supplies_and_Equipment__c  = testsprop.Supplies_and_Equipment__c  ;  
    sprop.Uniform__c = testsprop.Uniform__c; 
            update teststeadyResd;
    steadyResd.Scope_of_Work__c = teststeadyResd.Scope_of_Work__c ;
    upsert steadyResd;
    upsert sprop;   
    PageReference p = new PageReference('/' + this.sprop.Id );
    return p;
}
Public PageReference saveRecordpprop1(){
    lead.PCC_Proposal_Added__c  = true;
    upsert lead;
    update testpprop;
    update testfloorPO ;
    pprop.Contract_Terms__c = testpprop.Contract_Terms__c;
    pprop.Pricing_and_Agreement__c = testpprop.Pricing_and_Agreement__c;
    floorPO.Project_Overview__c = testfloorPO.Project_Overview__c;
    upsert floorPO; 
    upsert pprop;
    PageReference p = new PageReference('/' + this.pprop.Id );
    return p;
}
Public PageReference saveRecordpprop2(){
    lead.PCC_Proposal_Added__c  = true;
    upsert lead;
    update testpprop;
    update testgeneralpccPO;
    pprop.Contract_Terms__c = testpprop.Contract_Terms__c;
    pprop.Pricing_and_Agreement__c = testpprop.Pricing_and_Agreement__c;
    generalpccPO.Project_Overview__c = testgeneralpccPO.Project_Overview__c ;
    upsert generalpccPO;
    upsert pprop;   
    PageReference p = new PageReference('/' + this.pprop.Id );
    return p;
}
Public PageReference saveRecordpprop3(){
    lead.PCC_Proposal_Added__c  = true;
    upsert lead;
    update testpprop;
    update testwindowPO;
    pprop.Contract_Terms__c = testpprop.Contract_Terms__c;
    pprop.Pricing_and_Agreement__c = testpprop.Pricing_and_Agreement__c;
    windowPO.Project_Overview__c = testwindowPO.Project_Overview__c ;
    upsert windowPO;
    upsert pprop;   
    PageReference p = new PageReference('/' + this.pprop.Id );
    return p;
}
}
 
   Hello, can anyone help me in this question, in this method i am some custom record as well as attachment, my test class is running for custom records but it gives error "System.DmlException: Upsert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Body]: [Body]"

this is method's code , 

Public PageReference saveRecordlprop(){
lead.Labor_Mid_Construction_Proposal_Added__c = true ;
upsert lead;
update testlprop ; 
lprop.Marketing_Material__c = testlprop.Marketing_Material__c;
lprop.Holiday_Coverage__c = testlprop.Holiday_Coverage__c;
lprop.Management_and_Supervision__c = testlprop.Management_and_Supervision__c ;
lprop.Over_Time_Hours__c = testlprop.Over_Time_Hours__c ;
lprop.Payment_Terms__c = testlprop.Payment_Terms__c ;
lprop.Pricing__c = testlprop.Pricing__c ;
lprop.Statement_of_Work__c = testlprop.Statement_of_Work__c  ;
lprop.Supplies_and_Equipment__c = testlprop.Supplies_and_Equipment__c ;
lprop.Contract_Terms__c = testlprop.Contract_Terms__c;
insert lprop;
    
lpdocument = new Attachment();
lpdocument.Name = 'Client cover image';
lpdocument.ParentId = lprop.ID;
lpdocument.Body = lpfileBody;
upsert lpdocument;

lprop.Current_Record_ID__c = lpdocument.ID;

upsert lprop; 
    PageReference p = new PageReference('/' + this.lprop.Id );
    return p;
}

and this is my test class for this controller 

@isTest 
public class addProposalCntrltest2{

static testMethod void testMethod1() {

        Lead testRecord= new Lead();
        
        testRecord.LastName = 'test name ';
        testRecord.Company = 'test company';
        testRecord.Status = 'new';
        testRecord.Credit_Limit_Amount__c = 12344;
        

        insert testRecord;
        
        Laborer_Mid_Construction_Proposal__c testRecord2 = new Laborer_Mid_Construction_Proposal__c();
        testRecord2.Name = 'test';
        testRecord2.Lead__c= testRecord.ID;

        insert testRecord2 ;
        
    
        Blob lpfileBody  = Blob.valueOf('Test Data');
          Attachment attachment = new Attachment();
        attachment.Name = 'Test Attachment for Parent';
        attachment.ParentId = testRecord2.ID;
        attachment.Body = lpfileBody;
        
        insert attachment;
    
    
        Steady_Maintenance_Proposal__c testRecord3 = new Steady_Maintenance_Proposal__c();
        testRecord3.Name = 'test';
        testRecord3.Lead__c= testRecord.ID;

        insert testRecord3;
        
        Post_Construction_Cleanup_Proposal__c testRecord4 = new Post_Construction_Cleanup_Proposal__c();
         testRecord4.Name = 'test';
         testRecord4.Lead__c= testRecord.ID;

         insert testRecord4 ;
         
        Steady_Maintenance_Commercial__c testRecord5 = new Steady_Maintenance_Commercial__c();
        testRecord5.Name = 'test';
        testRecord5.Lead__c= testRecord.ID;

        Insert testRecord5;
        
        Steady_Maintenance_Residential__c testRecord6 = new Steady_Maintenance_Residential__c();
         testRecord6.Name = 'test';
         testRecord6.Lead__c= testRecord.ID;

         insert testRecord6 ;
         
         Floor_Cleaning_Project_Over_View__c  testRecord7 = new Floor_Cleaning_Project_Over_View__c();
         testRecord7.Name = 'test';
         testRecord7.Lead__c= testRecord.ID;

         insert testRecord7;
          
         General_PCC_Project_Over_View__c testRecord8 = new General_PCC_Project_Over_View__c();
         testRecord8.Name = 'test';
         testRecord8.Lead__c= testRecord.ID;

         insert testRecord8;
         
         Window_Cleaning_Project_Overview__c testRecord9 = new Window_Cleaning_Project_Overview__c();
         testRecord9.Name = 'test';
         testRecord9.Lead__c= testRecord.ID;

         insert testRecord9 ;
          



        Test.setCurrentPage(Page.addProposal);
        System.currentPageReference().getParameters().put('id', testRecord.Id);
        
        



        addProposalCntrl addProposalCntrlTestIns = new addProposalCntrl();
        
        addProposalCntrlTestIns.saveRecordlprop();
        addProposalCntrlTestIns.saveRecordspropComm();
        addProposalCntrlTestIns.saveRecordspropResd();
        addProposalCntrlTestIns.saveRecordpprop1();
        addProposalCntrlTestIns.saveRecordpprop2();
        addProposalCntrlTestIns.saveRecordpprop3();
        

        
    }
    private static void addAttachmentToParent(Id testRecord) {
        
    }
 }

Thank you!
    
Hello , 

i have two objects, 
1.Steady_Maintenance_Proposal__c
2.Steady_Maintenance_Commercial__c

both of these objects have Scope of work Rich Text area Fields, i want when ever Steady_Maintenance_Commercial__c object's rich text area field get created, it should automatically update the Steady_Maintenance_Proposal__c objects Scope of work, 
I have already tried work flow rule and process builder, both of these get saved with now errors, but dont update fields, 

i have added look up field of Steady_Maintenance_Commercial__c  on Steady_Maintenance_Proposal__c object ,

Please help me in this if any one has already came across this problem 


 
hello , my test class for this controller is giving 88% coverage, but it is not being deployed , can any one help me in this


public class addJobCntrl {

Public string leadID{get;set;}
Public Lead leadIns{get;set;}
Public Job__c jobIns{get;set;}
Public Job__c testjobIns{get;set;}


public addJobCntrl (){

leadID = apexpages.currentpage().getparameters().get('id');
leadIns= [select id, Company, State__c, Street__c , Zip__c , City__c , Type_of_Service_Proposal__c , Name  , Sales_Person__c, Insurance_Amount__c , Email, Credit_Application_received__c, Credit_Limit_Amount__c,  Phone from Lead where ID =: leadID ];
jobIns = new Job__c(Lead__c = leadID );


}


Public PageReference creatContract(){


jobIns.Name = leadIns.Company;
jobIns.Street__c = leadIns.Street__c ;
jobIns.State__c = leadIns.State__c ;
jobIns.Zipcode__c = leadIns.Zip__c ;
jobIns.City__c = leadIns.City__c ;
jobIns.Service_Type__c = leadIns.Type_of_Service_Proposal__c ;
jobIns.Billing_Contact__c = leadIns.Name  ;
jobIns.Billing_Email__c = leadIns.Email;
jobIns.Billing_Phone_Number__c =  leadIns.Phone;
jobIns.Credit_Application_received__c = leadIns.Credit_Application_received__c;
jobIns.Credit_Amount_Limit__c = leadIns.Credit_Limit_Amount__c;
jobIns.Insurance_Amount__c = leadIns.Insurance_Amount__c;
jobIns.Sales_Rep__c = leadIns.Sales_Person__c;

upsert jobIns;


PageReference p = new PageReference('/' + this.jobIns.Id );
return p;
}
}


this is Test class 

@isTest 
public class addJobCntrlTest{

static testMethod void testMethod1() {
       Account custIns = new Account();
       custIns.Name = 'test';
       custIns.QB_Company__c = 'qfs';
       custIns.QB_Account__c = 'test'; 
       custIns.Service_Type__c  = 'Mid-Construction';
       insert custIns;
       
       Job__c jobIns = new Job__c();
       jobIns.Name = 'test';
       jobIns.Sales_Rep__c = 'Aharon Kaplan';
       jobIns.Customer__c = custIns.ID;
       jobIns.Billing_Contact__c = 'test';  
       jobIns.Billing_Email__c= 'test@test.com'; 
       jobIns.Billing_Phone_Number__c= '123'; 
       jobIns.QB_Job_Name__c = 'test';   
       jobIns.QB_Company__c = 'QFS';
       
       insert jobIns;
       
       
        
       Lead testRecord= new Lead();
       testRecord.LastName = 'test name ';
       testRecord.Company = 'test company';
       testRecord.Status = 'new';
       testRecord.Credit_Limit_Amount__c = 12344;
       insert testRecord;
     

        Test.setCurrentPage(Page.addJob);
        System.currentPageReference().getParameters().put('id', testRecord.Id);

        addJobCntrl addjobCntrlTestIns = new addJobCntrl();
        
        addjobCntrlTestIns.creatContract();
    }
 }


and this is error i keep getting from test run 

upsert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Customer__c]: 

 
hello , i am not being able to run my test class for this controller , 

public class addLaborProposalCntrl {
    Public string leadID{get;set;}
    Public string testlpropID{get;set;}
    Public Lead lead {get;set;}
    Public Laborer_Mid_Construction_Proposal__c lprop {get;set;}
    Public Laborer_Mid_Construction_Proposal__c testlprop {get;set;}

    
    public addLaborProposalCntrl () {                  
    testlprop = [SELECT Marketing_Material__c, Holiday_Coverage__c,Management_and_Supervision__c, Over_Time_Hours__c, Pricing__c , Payment_Terms__c,Statement_of_Work__c,Supplies_and_Equipment__c FROM Laborer_Mid_Construction_Proposal__c where Name LIKE 'Test%' Limit 1 ];
    leadID = apexpages.currentpage().getparameters().get('id');
    lead = new Lead(ID = leadID);
    lprop = new Laborer_Mid_Construction_Proposal__c(Lead__c = LeadID );
    
    }
Public PageReference saveRecordlprop(){
upsert lead;
update testlprop ; 
lprop.Marketing_Material__c = testlprop.Marketing_Material__c;
lprop.Holiday_Coverage__c = testlprop.Holiday_Coverage__c;
lprop.Management_and_Supervision__c = testlprop.Management_and_Supervision__c ;
lprop.Over_Time_Hours__c = testlprop.Over_Time_Hours__c ;
lprop.Payment_Terms__c = testlprop.Payment_Terms__c ;
lprop.Pricing__c = testlprop.Pricing__c ;
lprop.Statement_of_Work__c = testlprop.Statement_of_Work__c  ;
lprop.Supplies_and_Equipment__c = testlprop.Supplies_and_Equipment__c ;
upsert lprop;  
    PageReference p = new PageReference('/' + this.lprop.Id );
    return p;
}


}

this is my Test Class 

@isTest 
public class addLaborProposalCntrlTest{

static testMethod void testMethod1() {

        Lead testRecord= new Lead();
        
        testRecord.LastName = 'test name ';
        testRecord.Company = 'test company';
        testRecord.Status = 'new';
        testRecord.Credit_Limit_Amount__c = 12344;
        insert testRecord;

        Laborer_Mid_Construction_Proposal__c testRecord2 = new Laborer_Mid_Construction_Proposal__c();
        testRecord2.Lead__C = testRecord.ID;
        testRecord2.Marketing_Material__c = 'test';
        testRecord2.Holiday_Coverage__c = 'test';
        testRecord2.Management_and_Supervision__c = 'test';
        testRecord2.Over_Time_Hours__c = 'test';
        testRecord2.Payment_Terms__c = 'test';
        testRecord2.Pricing__c = 'test';
        testRecord2.Statement_of_Work__c = 'test';
        testRecord2.Supplies_and_Equipment__c = 'test';
        
        
        testRecord2.Name = 'test';
        insert testRecord2;
        
        update testRecord2;
        


        Test.setCurrentPage(Page.addJob);
        System.currentPageReference().getParameters().put('id', testRecord2.Id);
        
        addLaborProposalCntrl addjobCntrlTestIns = new addLaborProposalCntrl();
        
        addjobCntrlTestIns.saveRecordlprop();
    }
 }

it gives this error 

System.TypeException: Invalid id value for this SObject type: a091g0000085HO8AAM error 

can anyone please help me in this 
 
Hello guys, can any one please help me creating test class which include multiple methods, 
my controller code is as 

public class addProposalCntrl {



   


    Public string leadID{get;set;}
    Public string testlpropID{get;set;}
    Public string testppropID{get;set;}
    Public string testspropID{get;set;}
    Public string testcommID{get;set;}
    Public string testresdID{get;set;}
    Public Lead lead {get;set;}
    
    Public string floorPOID{get;set;}
    Public string generalpccPOID{get;set;}
    Public string windowPOID{get;set;}

    
    Public Laborer_Mid_Construction_Proposal__c lprop {get;set;}
    Public Laborer_Mid_Construction_Proposal__c testlprop {get;set;}
    Public Laborer_Mid_Construction_Proposal__c lpropIns {get;set;}
    Public Steady_Maintenance_Proposal__c sprop {get;set;}
    Public Steady_Maintenance_Proposal__c testsprop {get;set;}
    Public Post_Construction_Cleanup_Proposal__c pprop {get;set;}
    Public Post_Construction_Cleanup_Proposal__c testpprop {get;set;}
    Public Steady_Maintenance_Commercial__c steadyComm{get;set;}
    Public Steady_Maintenance_Commercial__c teststeadyComm{get;set;}
    Public Steady_Maintenance_Residential__c steadyResd{get;set;}
    Public Steady_Maintenance_Residential__c teststeadyResd{get;set;}
    
    Public Floor_Cleaning_Project_Over_View__c  floorPO{get;set;}
    Public Floor_Cleaning_Project_Over_View__c  testfloorPO{get;set;}
    Public General_PCC_Project_Over_View__c generalpccPO{get;set;}
    Public General_PCC_Project_Over_View__c testgeneralpccPO{get;set;}
    Public Window_Cleaning_Project_Overview__c windowPO{get;set;}
    Public Window_Cleaning_Project_Overview__c testwindowPO{get;set;}







    


    public addProposalCntrl () {    
    
    testlpropID= 'a091g000004naaqAAA';
    testppropID = 'a0B1g0000033u90EAA';
    testspropID = 'a0A1g000000RlDZEA0';
    testcommID = 'a0C1g000000saTmEAI';
    testresdID = 'a0D1g000002274aEAA';
    floorPOID = 'a0b1g000001CBfXAAW';
    generalpccPOID = 'a0c1g000000UGEgAAO';
    windowPOID = 'a0a1g00000192O3AAI';
    
    
    testlprop = [SELECT Marketing_Material__c, Holiday_Coverage__c,Management_and_Supervision__c, Over_Time_Hours__c, Pricing__c , Payment_Terms__c,Statement_of_Work__c,Supplies_and_Equipment__c FROM Laborer_Mid_Construction_Proposal__c where ID =: testlpropID];
    testpprop = [SELECT Contract_Terms__c, Pricing_and_Agreement__c FROM  Post_Construction_Cleanup_Proposal__c where ID =: testppropID];
    testsprop = [SELECT Extraordinary_Maintenance_Requirements__c,Holiday_Coverage__c, Payment_Terms__c , Pricing__c, Sick_Pay__c, Supplies_and_Equipment__c  , Uniform__c , Marketing_Material__c FROM  Steady_Maintenance_Proposal__c where ID =: testspropID];
    teststeadyComm = [SELECT id, Scope_of_Work__c from Steady_Maintenance_Commercial__c  where id =: testcommID ];
    teststeadyResd = [SELECT id, Scope_of_Work__c from Steady_Maintenance_Residential__c where id =: testresdID ];
    testfloorPO = [select id, Project_Overview__c   from Floor_Cleaning_Project_Over_View__c  where id =: floorPOID ];
    testgeneralpccPO = [select id, Project_Overview__c  from General_PCC_Project_Over_View__c  where id =: generalpccPOID ];
    testwindowPO = [select id, Project_Overview__c  from Window_Cleaning_Project_Overview__c where id =: windowPOID  ];

    leadID = apexpages.currentpage().getparameters().get('id');
    lead = new Lead(ID = leadID);
    pprop = new Post_Construction_Cleanup_Proposal__c(Lead__c = LeadID);
    sprop  = new Steady_Maintenance_Proposal__c(Lead__c = LeadID);
    lprop = new Laborer_Mid_Construction_Proposal__c (Lead__c = LeadID );
    steadyComm = new Steady_Maintenance_Commercial__c (Lead__c = leadID);
    steadyResd = new Steady_Maintenance_Residential__c (Lead__c = leadID);  
    floorPO = new Floor_Cleaning_Project_Over_View__c (Lead__c = leadID);
    generalpccPO = new General_PCC_Project_Over_View__c (Lead__c = leadID);
    windowPO = new Window_Cleaning_Project_Overview__c (Lead__c = leadID);
    
    }
    
    

Public PageReference saveRecordlprop(){

upsert lead;
update testlprop ; 
lprop.Marketing_Material__c = testlprop.Marketing_Material__c;
lprop.Holiday_Coverage__c = testlprop.Holiday_Coverage__c;
lprop.Management_and_Supervision__c = testlprop.Management_and_Supervision__c ;
lprop.Over_Time_Hours__c = testlprop.Over_Time_Hours__c ;
lprop.Payment_Terms__c = testlprop.Payment_Terms__c ;
lprop.Pricing__c = testlprop.Pricing__c ;
lprop.Statement_of_Work__c = testlprop.Statement_of_Work__c  ;
lprop.Supplies_and_Equipment__c = testlprop.Supplies_and_Equipment__c ;


 insert lprop;
    
   
    
    PageReference p = new PageReference('/' + this.lprop.Id );
    return p;
}

Public PageReference saveRecordspropComm(){
    upsert lead;
    update testsprop;
    sprop.Marketing_Material__c = testsprop.Marketing_Material__c;
    sprop.Extraordinary_Maintenance_Requirements__c = testsprop.Extraordinary_Maintenance_Requirements__c;
    sprop.Holiday_Coverage__c = testsprop.Holiday_Coverage__c;
    sprop.Payment_Terms__c = testsprop.Payment_Terms__c;  
    sprop.Pricing__c = testsprop.Pricing__c;  
    sprop.Sick_Pay__c = testsprop.Sick_Pay__c;  
    sprop.Supplies_and_Equipment__c  = testsprop.Supplies_and_Equipment__c  ;  
    sprop.Uniform__c = testsprop.Uniform__c;  
    update teststeadyComm ;
    steadyComm.Scope_of_Work__c = teststeadyComm.Scope_of_Work__c ;
    
    
    upsert steadyComm;
    

    upsert sprop;
    PageReference p = new PageReference('/' + this.sprop.Id );
    return p;
}

Public PageReference saveRecordspropResd(){
    upsert lead;
    update testsprop;
    sprop.Marketing_Material__c= testsprop.Marketing_Material__c;
    sprop.Extraordinary_Maintenance_Requirements__c = testsprop.Extraordinary_Maintenance_Requirements__c;  
    sprop.Holiday_Coverage__c = testsprop.Holiday_Coverage__c;
    sprop.Payment_Terms__c = testsprop.Payment_Terms__c;  
    sprop.Pricing__c = testsprop.Pricing__c;  
    sprop.Sick_Pay__c = testsprop.Sick_Pay__c;  
    sprop.Supplies_and_Equipment__c  = testsprop.Supplies_and_Equipment__c  ;  
    sprop.Uniform__c = testsprop.Uniform__c; 
            update teststeadyResd;
    steadyResd.Scope_of_Work__c = teststeadyResd.Scope_of_Work__c ;
    upsert steadyResd;
    upsert sprop;   
    PageReference p = new PageReference('/' + this.sprop.Id );
    return p;
}
Public PageReference saveRecordpprop1(){
    lead.PCC_Proposal_Added__c  = true;
    upsert lead;
    update testpprop;
    update testfloorPO ;
    pprop.Contract_Terms__c = testpprop.Contract_Terms__c;
    pprop.Pricing_and_Agreement__c = testpprop.Pricing_and_Agreement__c;
    floorPO.Project_Overview__c = testfloorPO.Project_Overview__c;
    upsert floorPO; 
    upsert pprop;
    PageReference p = new PageReference('/' + this.pprop.Id );
    return p;
}
Public PageReference saveRecordpprop2(){
    lead.PCC_Proposal_Added__c  = true;
    upsert lead;
    update testpprop;
    update testgeneralpccPO;
    pprop.Contract_Terms__c = testpprop.Contract_Terms__c;
    pprop.Pricing_and_Agreement__c = testpprop.Pricing_and_Agreement__c;
    generalpccPO.Project_Overview__c = testgeneralpccPO.Project_Overview__c ;
    upsert generalpccPO;
    upsert pprop;   
    PageReference p = new PageReference('/' + this.pprop.Id );
    return p;
}
Public PageReference saveRecordpprop3(){
    lead.PCC_Proposal_Added__c  = true;
    upsert lead;
    update testpprop;
    update testwindowPO;
    pprop.Contract_Terms__c = testpprop.Contract_Terms__c;
    pprop.Pricing_and_Agreement__c = testpprop.Pricing_and_Agreement__c;
    windowPO.Project_Overview__c = testwindowPO.Project_Overview__c ;
    upsert windowPO;
    upsert pprop;   
    PageReference p = new PageReference('/' + this.pprop.Id );
    return p;
}
}