• Patrick Sluck 5
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
I am working on a VF Page for "Trip Reports", eseentially visits.  I would like to select multiple contacts from the account associated to the Trip Report Object.  I have gotten to a point where I can see my, "Add Attendees" button, but it is not rendering a table of contacts to select. Once I figure this out I need to do the same with Users.  Any assistance would be greatly appreciated!!!!

Below is my code.

<apex:page standardController="Trip_Report__c" extensions="ReturnToObject" >
    <style>
      .activeTab {background-color: #2ECCFA; color:white; 
         background-image:none}
      .inactiveTab { background-color: lightgrey; color:black; 
         background-image:none}
   </style>
    <script>
        function confirmSave() {
            var isSave = confirm("Your Trip Report has been saved!");
            if (isSave) return true;
  
        return false;
        }
    </script>
    <!-- Include reference for jQuery -->
      <apex:includeScript value="{!URLFOR($Resource.jQuery,'js/jquery-1.7.2.min.js')}"/>
      <apex:includeScript value="{!URLFOR($Resource.jQuery2, 'js/jquery-ui-1.8.19.custom.min.js')}"/>
      <apex:stylesheet value="{!URLFOR($Resource.jQuery2, 'css/ui-lightness/jquery-ui-1.8.19.custom.css')}"/>
      
   <script type="text/javascript">
   
       var j$= jQuery.noConflict();
       
       j$(document).ready(function(){
           j$('#openContactDialog').click(function(){
               j$('#contactListDialog').dialog({
               buttons:{'Ok': function(){ j$(this).dialog("close");},'Cancel':function(){}
               }, modal:true,title:"contacts",width:800, closeOnEscape:true, draggable:false, resizable:false,show:"fade",position:"center"});
           });
       });
       
       
        function openContactListDialog() {
        j$("#contactListDialog")
            .find("input:checked")
                .each(function() {
                    this.checked = false;
                })
            .end()
            .dialog("open");
    }
   </script>
    <apex:form >
        <apex:pageBlock title="Trip Report">
            <apex:pageBlockButtons >
                <apex:commandButton value="Save As Draft" action="{!saveAndReturn}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
                <apex:commandButton action="/flow/TR Has Been Submitted" value="Submit" />
            </apex:pageBlockButtons>
        <apex:pageBlockSection columns="1"> 
            <apex:outputfield value="{!Trip_Report__c.Account__c}"/>
            <apex:inputfield required="true" value="{!Trip_Report__c.Name}" label="Visit"/>
            <font style="margin-left:240px" size="0.25" color="blue"> <b> Enter: 'TR'-Company Name-Subject for the Visit</b></font>
            <apex:inputfield required="true" value="{!Trip_Report__c.Purpose_of_Visit__c}" label="Purpose Of Visit"/>
            <apex:inputfield value="{!Trip_Report__c.Visit_Date__c}" label="Date"/>
            <apex:inputfield value="{!Trip_Report__c.Lead_Source__c}" label="Lead Source"/>
            <apex:inputfield value="{!Trip_Report__c.Opportunity__c}" label="Opportunity"/>
            <apex:inputfield value="{!Trip_Report__c.Campaign__c}" label="Campaign"/>
        </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
    <apex:form rendered="{!ISNULL(Trip_Report__c.Attendees__c)}">
        <apex:pageBlock title="Attendees">
            <apex:pageBlockSection columns="3">
                <apex:outputPanel layout="block">
                <div>
                  <input type="button" value="Delete"/>
                  <input type="button" value=" Add Attendee(s)" id="openContactDialog" />
                    <input type="button" value="Add PL Attendee(s)"/>
                </div>
                </apex:outputPanel>
                
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>    
    <div id="contactListDialog" style="display: none;">
        <apex:form id="contactListForm">
        
            <apex:outputPanel styleClass="dataGrid" layout="block" >
                <table id="contactListTable" border="0" cellspacing="0" cellpadding="0">
                    <thead>
                        <tr>
                            <th class="first" scope="col"><img src="/s.gif" alt="" border="0" width="1" height="1" /></th>
                            <th scope="col"><apex:outputText value="{!$ObjectType.Contact.Fields.Name.Label}" /></th>
                            <th scope="col"><apex:outputText value="{!$ObjectType.Contact.Fields.title.Label}" /></th>
                            <th scope="col"><apex:outputText value="{!$ObjectType.Contact.Fields.Phone.Label}" /></th>
                            <th scope="col"><apex:outputText value="{!$ObjectType.Contact.Fields.Email.Label}" /></th>
                        </tr>
                    </thead>
                    
                </table>
            </apex:outputPanel>
        </apex:form>
    </div>
    <apex:form >
        <div>
            <apex:pageBlock title="Trip Details & Notes">
            <apex:tabPanel switchType="client" selectedTab="sch" tabclass="activeTab" inactivetabclass="inactiveTab">
                <apex:tab label="Objectives">
                    <apex:inputfield value="{!Trip_Report__c.Objectives__c}" label="Objectives/Reason For Visit" style="width: 1250px; height: 100px"/>
                </apex:tab>
                <apex:tab label="Background">
                    <apex:inputfield value="{!Trip_Report__c.Background__c}" label="Background Information" style="width: 1250px; height: 100px"/>
                </apex:tab>
                <apex:tab label="Discussions">
                    <apex:inputfield value="{!Trip_Report__c.Discussion__c}" label="Discussions" style="width: 1250px; height: 100px"/>
                </apex:tab>
                <apex:tab label="Trip Summary">
                    <apex:inputfield value="{!Trip_Report__c.Summary__c}" label="Trip Summary" style="width: 1250px; height: 100px"/>
                </apex:tab>
                <apex:tab label="Actions/Questions">
                    <apex:inputfield value="{!Trip_Report__c.Actions_Questions__c}" label="Actions/Questions" style="width: 1250px; height: 100px"/>
                </apex:tab>
            </apex:tabPanel>
            </apex:pageBlock>
        </div>
    </apex:form>
</apex:page>
On line 10 of my Class, I get the error listed in the subject line above.  Unsure how to resolve.  I am working on adding the attachments option to my VF Page listed below as well.  Please help!!

public class VFAttachments {
        public Id recordId;

    public VFAttachments() {
        
    }


    public VFAttachments(ApexPages.StandardController controller) {
        this.recordId = (Trip_Report__c)standardController.getRecord().Id;
    }


public Attachment attachment {
  get {
      if (attachment == null)
        attachment = new Attachment();
      return attachment;
    }
  set;
  }

  public PageReference upload() {

    attachment.OwnerId = UserInfo.getUserId();
    attachment.ParentId = recordId; // the record the file is attached to
 //   attachment.ParentId = ApexPages.currentPage().getParameters().get('id'); 
    attachment.IsPrivate = true;

    try {
      insert attachment;
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    } finally {
      attachment = new Attachment(); 
    }

    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
    return null;
  }
}


VF Page Below....

<apex:page standardController="Trip_Report__c" >
    <style>
      .activeTab {background-color: #2ECCFA; color:white; 
         background-image:none}
      .inactiveTab { background-color: lightgrey; color:black; 
         background-image:none}
   </style>
    <script>
        function confirmSave() {
            var isSave = confirm("Your Trip Report has been saved!");
            if (isSave) return true;
  
        return false;
        }
    </script>
    <apex:form >
        <apex:pageBlock title="Trip Report">
            <apex:pageBlockButtons >
                <apex:commandButton value="Save As Draft" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
                <apex:commandButton value="Delete" action="{!delete}"/>
            </apex:pageBlockButtons>
        <apex:pageBlockSection columns="1">      
            <apex:inputfield required="true" value="{!Trip_Report__c.Name}" label="Visit"/>
            <font style="margin-left:240px" size="0.25" color="blue"> <b> Enter: 'TR'-Company Name-Subject for the Visit</b></font>
            <apex:inputfield required="true" value="{!Trip_Report__c.Purpose_of_Visit__c}" label="Purpose Of Visit"/>
            <apex:inputfield value="{!Trip_Report__c.Visit_Date__c}" label="Date"/>
            <apex:inputfield value="{!Trip_Report__c.Lead_Source__c}" label="Lead Source"/>
            <apex:inputfield value="{!Trip_Report__c.Opportunity__c}" label="Opportunity"/>
            <apex:inputfield value="{!Trip_Report__c.Campaign__c}" label="Campaign"/>
        </apex:pageBlockSection>
        <apex:pageBlock title="Attendees">
            <apex:pageBlockSection columns="2">
                <apex:inputfield value="{!Trip_Report__c.Attendees__c}" label="Client Attendees"/>
                <apex:inputfield value="{!Trip_Report__c.PL_Attendees__c}" label="Internal Attendees"/>
            </apex:pageBlockSection>
        </apex:pageBlock>    
        <div>
            <apex:pageBlock title="Trip Details & Notes">
            <apex:tabPanel switchType="client" selectedTab="sch" tabclass="activeTab" inactivetabclass="inactiveTab">
                <apex:tab label="Objectives">
                    <apex:inputfield value="{!Trip_Report__c.Objectives__c}" label="Objectives/Reason For Visit" style="width: 1250px; height: 100px"/>
                </apex:tab>
                <apex:tab label="Background">
                    <apex:inputfield value="{!Trip_Report__c.Background__c}" label="Background Information" style="width: 1250px; height: 100px"/>
                </apex:tab>
                <apex:tab label="Discussions">
                    <apex:inputfield value="{!Trip_Report__c.Discussion__c}" label="Discussions" style="width: 1250px; height: 100px"/>
                </apex:tab>
                <apex:tab label="Trip Summary">
                    <apex:inputfield value="{!Trip_Report__c.Summary__c}" label="Trip Summary" style="width: 1250px; height: 100px"/>
                </apex:tab>
                <apex:tab label="Actions/Questions">
                    <apex:inputfield value="{!Trip_Report__c.Actions_Questions__c}" label="Actions/Questions" style="width: 1250px; height: 100px"/>
                </apex:tab>
            </apex:tabPanel>
            </apex:pageBlock>
        </div>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Here is the code I am working with.  I am already at 15 relationship on the Opportunity Object otherwise I would do this with a formula field.

trigger SetPrimaryContactEmail on Opportunity (before insert, before update) {
  Set<ID> setConIds = new Set<ID>();
    for(Opportunity obj : trigger.new)
   {
         if(obj.Primary_Contact__c != null)
            setConIds.add(obj.Primary_Contact__c);
   }

  MAP<ID , Contact> mapCon = new MAP<ID , Contact>([Select Email from Contact where id in: setConIds]);

   for(Case obj : trigger.new)
   {
        if(obj.Primary_Contact__c != null)
          {
            Contact c = mapCon.add(obj.Primary_Contact__c);
            obj.Primary_Contact_Email__c = c.Email;
          }
       
   }
}
Here is the code I am working with.  I am already at 15 relationship on the Opportunity Object otherwise I would do this with a formula field.

trigger SetPrimaryContactEmail on Opportunity (before insert, before update) {
  Set<ID> setConIds = new Set<ID>();
    for(Opportunity obj : trigger.new)
   {
         if(obj.Primary_Contact__c != null)
            setConIds.add(obj.Primary_Contact__c);
   }

  MAP<ID , Contact> mapCon = new MAP<ID , Contact>([Select Email from Contact where id in: setConIds]);

   for(Case obj : trigger.new)
   {
        if(obj.Primary_Contact__c != null)
          {
            Contact c = mapCon.add(obj.Primary_Contact__c);
            obj.Primary_Contact_Email__c = c.Email;
          }
       
   }
}