• Lisa Horne
  • NEWBIE
  • 65 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 13
    Replies

I have this apex trigger but getting the following error when trying to delete contract product from an opportunity.  Could someone please let me know what I need to fix so I can delete contract products?

trigger Contract_Product_Delete_Update_Accounts_and_Contracts on Contract_Product__c (after delete) 
{  
  system.debug('DELETE TRIGGER FIRSTRUN VARIABLE: ' + Account_Contract_Update_Class.FirstRun);
  if(Account_Contract_Update_Class.FirstRun == true)
  {
    Account_Contract_Update_Class.FirstRun = false;
    system.debug('CONTRACT PRODUCT DELETE TRIGGER!!!!');
    String ObjectDMLType ='ContractProductDelete';
    set<ID> TheseAccountIDs = new set<id>(); //Set of Account IDs that have Contract Products. 
                        //These Accounts Need to be updated by checking All their active Contract Products
    set<id> TheseContractIDs = new set<id>();                      
    list<string> Products = new list<string>();
    for(Contract_Product__c cp : trigger.old)
    {
      TheseAccountIds.add(cp.Account__c);  
      TheseContractIds.add(cp.Contract__c);  
      Products.add(string.valueof(cp.Product_Family__c));
    }    
    system.debug('Number of Products removed: ' + trigger.old.size());  
    system.debug('These are the accounts that will be updated: ' + TheseAccountIds);
    system.debug('These are Products being deleted: ' + Products);    
    
    //Update the Contract
    Account_Contract_Update_Class.UpdateContracts(TheseContractIDs, ObjectDMLType);  
    //Update the Account
    Account_Contract_Update_Class.UpdateAccounts(TheseAccountIDs, ObjectDMLType);
  }
//last brackett
}


 

ERROR I am getting:
Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger Contract_Product_Delete_Update_Accounts_and_Contracts caused an unexpected exception, contact your administrator: Contract_Product_Delete_Update_Accounts_and_Contracts: execution of AfterDelete caused by: System.QueryException: No such column 'BillingAddress' on entity 'Contract'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.: Class.Account_Contract_Update_Class.UpdateContracts: line 238, column 1". 

Click here to return to the previous page.
 

I created a VF page for a custom object and would like to have the column header "Certification Year" sorted by default in decending order.

Is there an easy way to do this without a controller? I'm new to coding and am not familiar with this. Or can someone help me with getting it done?

This is the code I have for the visualforce page:


<apex:page standardController="Account">
   
      You are viewing the {!account.name} account.

      <apex:pageBlock title="ONS's">

      <apex:pageBlockTable value="{!account.ONC_s__r}" var="onc">

         <apex:column value="{!onc.Name}"/>
         <apex:column value="{!onc.Owner.name}"/>
         <apex:column value="{!onc.Certification_Year__c}"  />
         <apex:column value="{!onc.Practice_Setting__c}"/>
         

      </apex:pageBlockTable>

   </apex:pageBlock>

</apex:page>
I want to create a VF page on the Account that will display the related list of the HL Contracts records that have a look up to the Account.

I have the following but it gives me this error:  Content cannot be displayed: 'HLContracts__r' is not a valid child relationship name for entity Account

This is the code I have:

<apex:page standardController="Account">
<apex:relatedList list="HLContracts__r" />
</apex:page>


 
I have the following trigger  and I am getting this error on the Test Class.  Could someone point out what I am doing wrong on the test class?

API Name
Type
Line
Column
Problem
TestCreateTaskOnInsertWebToLead.TestCreateTaskOnInsertWebToLead() Class 35 1 Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []", Failure Stack Trace: "Class.TestCreateTaskOnInsertWebToLead.TestCreateTaskOnInsertWebToLead: line 35, column 1"

Trigger
User-added image

Class
User-added image
The Contact Role object can not have fields added to it.  In order to get around this I have created a custom object  with an Object Name= OpportunityContactRoles and gave it a child relationship to the opportunity object.  The custom object has the two fields that are on the Contact Role object, ContactID and Object Name Parts (same as Role), but also has additional fields on it.

What I would like to have happen is every time a Contact name and Parts has been entered into the custom object and saved, a new  standard Contact Role is automatically created on the opportunity with the same Contact name and Role (Parts).  Can anyone help me with a trigger and class for this?  So far I have this but I know it's not even close.


trigger new_Contact_Role_to_Standard on Contact Role
{
   for(Contact Role c : Trigger.New)
   {
        OpportunityContactRole o = new OpportunityContactRole;
        o.ContactId = set the contact id here;
        o.OpportunityId = set the Opportunity id here;
        insert o;
   }
}
I need some assitance with creating a Trigger that creates a task from a lead record that has text in the Lead Web Comment Field to create a task for the Lead owner, with priority of Normal, Subject of Text "Lead Web Comment", Status of Lead Web Comment.

I have this trigger started but don't know exactly how to have all the fields populated with the above requirements.

Could someone please help?


trigger Lead_After_Insert on Lead (after insert)

{
  list<Task> lNewTasks = new list<Task>();

  for(integer i=0; i<trigger.new.size(); i++)

  {

     lNewTasks.add(MyTask = new Task(

       Subject = 'Lead Web Comment',

       WhoID = trigger.new[i].id

       *Other Task Fields Here*

     );

   }

   insert lNewTasks;

}

As you know, the Contact Role object can not have fields added to it.  In order to get around this I have created a custom object called Contact Roles and gave it a child relationship to the opportunity object.  The custom object has the same two fields that are on the Contact Role object, ContactID and Role, but also has additional fields on it.

What I would like to have happen is every time a Contact name and Role has been entered into the custom object and saved, a new Contact Role is automatically created on the opportunity with the same Contact name and Role.  Does anyone know of a solution for this?

 

Regards,

Andrew