• Rob Easton 1
  • NEWBIE
  • 0 Points
  • Member since 2016

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

public class AccountHandler{
    
public static Account insertNewAccount (String accName){ 

   if(accName!=''){    
       try{
           Account a = new Account(Name=accName);
           insert a;
           System.debug('Bravo User5633! Account created');
           return a;
       } catch(Exception e){
           System.Debug('Account not created');
           return null;
       }
   } else {
       return null;
   }
}
}    

</code>    

Challenge Not yet complete... here's what's wrong: 
Executing the 'insertNewAccount' method failed. Either the method does not exist, is not static, or does not insert the proper account.
I am trying to build a SOQL query with the Opportunity, OpportunityContactRoles and Contact Objects. The Opportunity Contact Roles object does not have the AccountID (nor does Salesforce.com allows you to create a custom field to this table) therefore in order for your query to have the Account Name of those contacts you have under your contact roles you must link the contact table to the OpportunityContactRoles. In our case we can select contacts in our OpportunityContactRoles that ARE NOT a contact of the Account link to the Opportunity such as a partner or a consultant.

The purpose of this query is to create Consultant Bios from those consultants participating in our Campaigns. In the Bios we would like to list the opportunities of the consultants account regardless of who they are sending to participate in our campaigns. 

The data would look like this.

Campaign Particpant
Consultant Account: ABC
Consultant Campaign Member:  John Doe

List of Opportunties based on where opportunitycontactroles AccountID = Campaign Member AccountID
Opportunity            Account
02100                    Candyland
02101                    Frosties

This is the code that I have at the moment and whenever I try to add the contact table I get an error. 

SELECT RecordTypeDesc__c, Id, Name, Opportunity_Number__c, AccountId, Account_Name__c, 
(SELECT ContactId,OpportunityId,Role FROM OpportunityContactRoles) 
FROM Opportunity
WHERE RecordTypeDesc__c = 'Project'