• GWebber
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies

I'm new to VisualForce.  I've been following the tutorials, but I can't for the life of me get this variable declared properly it seems.  Anyone have an idea why it would think that opp doesn't exist as a variable?

 

 

public class RevenueProjectionController {
        public Opportunity opp { get; set; }
        
        public RevenueProjectionController()
        {
            opp = new Opportunity();
        }
        
        public static List<Opportunity> getEvents() {
                
                return [SELECT Id, Name, Account.Name 
                        FROM Opportunity
                        WHERE Event_Date__c >= :opp.Event_Date__c
                        ORDER BY Probability, Event_Date__c];
        }
        
        
        static testMethod void testCases() {
                List<Opportunity> test = new List<Opportunity>();
                test = getEvents();
        }
}

 

 

I'm having some difficulties creating an e-mail service that creates Contacts, which can then be linked to an Opportunity using OpportunityContactRole.  I'm not getting e-mail error logs when I send my tests, so I can't figure out what's going wrong.  Here's the key bit of the code that I think is not working properly:

 

 

if(!event_code.equals(''))
          {
               Opportunity opp = [Select ID
                   From Opportunity Where Event_Code__c = :event_code limit 1];
               
               Contact primaryContact = new Contact();
               primaryContact.LastName = event_last;
               primaryContact.FirstName = event_first;
               try{
               insert primaryContact;
               }catch(DMLException e){
                     system.debug('ERROR Inserting attachment:'+e.getDMLMessage(0));
               } 

               OpportunityContactRole primaryContactRole = new OpportunityContactRole();
               primaryContactRole.ContactId = primaryContact.id;
               primaryContactRole.OpportunityId = opp.id;
               try{
                     insert primaryContactRole;
               }catch(DMLException e){
                     system.debug('ERROR Inserting attachment:'+e.getDMLMessage(0));
               } 
          }

 

 

I am very new to Apex development.  I have the general idea of what I need to do, but do not know how to execute on it.

 

I need to take incoming e-mails and, using an e-mail service, add their attachments to corresponding Opportunities.  These e-mails are all formatted the same, so I have to parse and find the line that starts "Event Code: " and take the six digit code after that to find the appropriate Opportunity instance.


I've found this post from a while back, which has code that does almost exactly what I want.  However, the biggest problem for me is parsing through the document to find that "Event Code: " line.

 

Any help would be greatly appreciated.

I'm new to VisualForce.  I've been following the tutorials, but I can't for the life of me get this variable declared properly it seems.  Anyone have an idea why it would think that opp doesn't exist as a variable?

 

 

public class RevenueProjectionController {
        public Opportunity opp { get; set; }
        
        public RevenueProjectionController()
        {
            opp = new Opportunity();
        }
        
        public static List<Opportunity> getEvents() {
                
                return [SELECT Id, Name, Account.Name 
                        FROM Opportunity
                        WHERE Event_Date__c >= :opp.Event_Date__c
                        ORDER BY Probability, Event_Date__c];
        }
        
        
        static testMethod void testCases() {
                List<Opportunity> test = new List<Opportunity>();
                test = getEvents();
        }
}