• JamieD
  • NEWBIE
  • 0 Points
  • Member since 2009

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

I am having an issue with something that sounds so simple to me.  Here is the APEX trigger:

 

trigger LinkTimeCard on Timecard__c (after insert) {
    System.debug('Starting...');
    for (Timecard__c tc : Trigger.new) {
        tc.Account = tc.Case__r.Account;
    }
}

 

The Timecard custom object has a lookup relationship with Account and Master-Detail relationship with Case.  The other odd thing to me is the following:

 

trigger LinkTimeCard on Timecard__c (after insert) {
    System.debug('Starting...');
    for (Timecard__c tc : Trigger.new) {
        System.debug(tc.Case__r.CaseNumber);
    }
}

 

That shows "null" in the debug log.  I can't really find any API documentation in APEX that shows a class library like you would find for Java or .NET.  Why can't I access the object Case__r?

A few days ago I started toying around with the cases and contracts area, trying to link them together using a custom "hours" field in order to total all billed hours for that particular contract.  I have been trying to use the Account associated with both the contract and the case to accomplish this without any luck.  At the very basic level, I want to accomplish the following:

 

1) Create a custom formula in Account which totals the hours used for the current month.

2) Cross reference that formula in several reports leveraging contract data.  Since I have full access to the Account object from Contracts, I assume this will be easy.

 

I finally gave up after creating a custom lookup field from Case to Account and not being able to total the hours field.  Any help would be greatly appreciated! 

  • April 14, 2009
  • Like
  • 0