• Andrew Byrns
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
User-added image

I'd like to write a trigger that will modify the opportunity when an approval is approved. The snapshot shows an approval for discounts. When the discount is too high for a particular opportunity it is flagged for approval. Once the approver approves the opportunity I'd like a few fields to be autofilled. What object do I need to attach this trigger to, if this is indded possible? I would assume that some object exists for the approval. 

​In the Eclipse Force.com IDE I don't see any object for approval when writing new triggers. Your thoughts/assistance are much appreciated!
 
Seriously, code coverage will be the death of me! This test is not returning any coverage and I can't figure out why. Any suggestions?

Here's the trigger. It's supposed so transfer two dates from the relationship field Opportunity__c on the contract when the contract record is updated. However in the developer console the code coverage is 0%.
 
trigger TransferOpportunityValue on Contract (before update) { 
     
    for(Contract c : Trigger.new){

        if(c.Opportunity__c != null){

        	Opportunity o = [Select id,Pay_History_Received__c,Pay_History_Reviewed__c From Opportunity Where Id = :c.Opportunity__c];
			c.Pay_History_Received__c = o.Pay_History_Received__c;
			c.Pay_History_Reviewed__c = o.Pay_History_Reviewed__c;
            
        }

    }

}

The test class is here, I'm updating the field price_level__c, but to no avail the coverage is still 0% and there are definitely activated contracts. Anyone have any idea why? You help is much appreciated.
 
@isTest

private class TestUpdateContract {
    
    static testMethod void myTest() {

        Contract con; 
        con= [SELECT Id,price_level__c FROM Contract LIMIT 1];
         
        con.price_level__c = '12345';
        update con;           
        
    }

}


 
Seriously, code coverage will be the death of me! This test is not returning any coverage and I can't figure out why. Any suggestions?

Here's the trigger. It's supposed so transfer two dates from the relationship field Opportunity__c on the contract when the contract record is updated. However in the developer console the code coverage is 0%.
 
trigger TransferOpportunityValue on Contract (before update) { 
     
    for(Contract c : Trigger.new){

        if(c.Opportunity__c != null){

        	Opportunity o = [Select id,Pay_History_Received__c,Pay_History_Reviewed__c From Opportunity Where Id = :c.Opportunity__c];
			c.Pay_History_Received__c = o.Pay_History_Received__c;
			c.Pay_History_Reviewed__c = o.Pay_History_Reviewed__c;
            
        }

    }

}

The test class is here, I'm updating the field price_level__c, but to no avail the coverage is still 0% and there are definitely activated contracts. Anyone have any idea why? You help is much appreciated.
 
@isTest

private class TestUpdateContract {
    
    static testMethod void myTest() {

        Contract con; 
        con= [SELECT Id,price_level__c FROM Contract LIMIT 1];
         
        con.price_level__c = '12345';
        update con;           
        
    }

}


 
Seriously, code coverage will be the death of me! This test is not returning any coverage and I can't figure out why. Any suggestions?

Here's the trigger. It's supposed so transfer two dates from the relationship field Opportunity__c on the contract when the contract record is updated. However in the developer console the code coverage is 0%.
 
trigger TransferOpportunityValue on Contract (before update) { 
     
    for(Contract c : Trigger.new){

        if(c.Opportunity__c != null){

        	Opportunity o = [Select id,Pay_History_Received__c,Pay_History_Reviewed__c From Opportunity Where Id = :c.Opportunity__c];
			c.Pay_History_Received__c = o.Pay_History_Received__c;
			c.Pay_History_Reviewed__c = o.Pay_History_Reviewed__c;
            
        }

    }

}

The test class is here, I'm updating the field price_level__c, but to no avail the coverage is still 0% and there are definitely activated contracts. Anyone have any idea why? You help is much appreciated.
 
@isTest

private class TestUpdateContract {
    
    static testMethod void myTest() {

        Contract con; 
        con= [SELECT Id,price_level__c FROM Contract LIMIT 1];
         
        con.price_level__c = '12345';
        update con;           
        
    }

}