• Mani Anand 10
  • 0 Points
  • Member since 2017

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2
I am trying to add  existing contacts to a related list on Opportunities  as "Job Candidates" through a VF page and kicked off by a custom button. I keep getting the compile Error  Error: Compile Error: Invalid field OpportunityId for SObject Contact at line 35 column 75 .  The functionailty is suppose to search contacts (which i should make for specific record type of "participant"  and "Participant Donor" just haven't gotten there yet. 

What am I missing? 

public with sharing class AddContacttoJobOpptController { 
    public Opportunity opp {get;set;}
      public String selectedConId = '';
    public String selectedOppId = '';
    public AddContacttoJobOpptController(){
        opp = new Opportunity();
        selectedOppId = Apexpages.currentPage().getParameters().get('aid');
    public Pagereference addContact(){
        Set<String> conIdSet = new Set<String>();
        selectedConId = opp.Candidate__c;
        if(selectedConId != null && selectedConId != ''){
            for(Contact con : [select id from Contact where OpportunityId = :selectedOppId]){
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact is already added to strategic account plan. Please select another contact to add.');
                return null;
                Contact con = new Contact(id=selectedConId, OpportunityId=selectedOppId);
                update con;
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact has been added to strategic account plan. Now you can select another contact to add.');
                return null;
            apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'Please select contact then click on Add Contact button.');
            return null;
    public Pagereference goBack(){
        return new Pagereference('/'+selectedOppId);


Hi All -


I am new, so please forgive my green - but I am having a perplexing problem in generating a Visual Force email template showing related lists for a custom object.


I CAN get a list of Cases related to an Account with no problem, but when I put in a custom object  (Child Relationship Name "Suppliers") which is also (Master-Detail) related to Account I get the following error: Error: Invalid field Suppliers for SObject Account


I have tried everything I can think of - using API name instead, appending "__c" to the end, but it seems that i can't make any lists at all with custom objects in this code.


Is there a restriction within this type of code that allows only lists with standard objects or is there something I'm missing?


Any help would be greatly appreciated. I am not good enough to make a custom Apex controller yet and a little under the gun to kluge something together.


Thanks much,




Below is relevant code:



<messaging:emailTemplate recipientType="Contact"
    subject="Supplier report for Account: {!relatedTo.name}"
    replyTo="support@acme.com" >
<messaging:htmlEmailBody >   
     <STYLE type="text/css">
           TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center }
           TD  {font-size: 11px; font-face: verdana }
           TABLE {border: solid #CCCCCC; border-width: 1}
           TR {border: solid #CCCCCC; border-width: 1}
         <font face="arial" size="2">
      <p>Dear {!recipient.name},</p>
      <p>Below is a list of supplier records related to the account: {!relatedTo.name}.</p>
<table border="0" >
        <tr >
            <th>Action</th><th>Product</th><th>Status</th><th>Creator Email</th><th>BL date</th>
<apex:repeat var="cx" value="{!relatedTo.Suppliers}">
       <td><a href="https://na1.salesforce.com/{!cx.id}">View</a> |  
       <a href="https://na1.salesforce.com/{!cx.id}/e">Edit</a></td>