• mikemelnick
  • NEWBIE
  • 0 Points
  • Member since 2011

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

Good Morning,

 We have been looking for a way to create a query on the contact screen to enhance the Opportunity Roles information.  We have created a VF page with tabs to display this information and both the page and extension work correctly in the sandbox. 

 

The relevant code for the VF page:

 

<apex:page standardController="Contact" extensions="OpportunityContactController" showHeader="true" tabStyle="contact" >

.

.

<apex:tab label="Donation Roles" name="OpportunityContactRoles" id="tabOppConRole">

         <apex:form >

             

              <apex:pageblock mode="edit" id="CustomList" title="Contact Roles"  >

             

                   <apex:pageBlockTable value="{!roles}" var="o" rendered="{!NOT(ISNULL(roles))}">

                       <apex:column value="{!o.OpportunityId}"/>

                       <apex:column value="{!o.Opportunity.Amount}"/>

                       <apex:column value="{!o.Opportunity.StageName}"/>

                       <apex:column value="{!o.Role}"/>

                       <apex:column value="{!o.CreatedDate}"/>

                   </apex:pageBlockTable>

                    

                   <apex:outputLabel value="No records to display" rendered="{!(ISNULL(roles))}" styleClass="noRowsHeader">

                   </apex:outputLabel>

                     

              </apex:pageblock>

                 

         </apex:form>

      </apex:tab>

 

 

The controller class:

 

public with sharing class OpportunityContactController {

 

// the soql

  private String soql {get;set;}

 

  // the collection of contact roles to display

 

  private List<OpportunityContactRole> roles;

 

  public List<OpportunityContactRole> getroles()

  {

        return roles;

  }

 

  // the contact id

  private Contact ContId;

 

  public OpportunityContactController(ApexPages.StandardController controller) {

          this.ContId= (Contact)controller.getRecord();

 

      soql = 'SELECT Role, OpportunityId, Id, ContactId, opportunity.amount, opportunity.stagename, CreatedDate From OpportunityContactRole where ContactId = \''+ContId.Id+'\'';

      queryRole();

  }

 

    // runs the actual query

  public void queryRole() {

 

    try {

      roles = Database.query(soql);

    } catch (Exception e) {

      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'SOQL Error - Please contact your SalesForce Administrator'));

    }

 

  }

}

 

When we created a test for this extension, we get a "Constructor not defined" error on the underlined piece of code below.  The test class:

@isTest

private with sharing class TEST_OpportunityContact {

 

   static testMethod void myUnitTest() {

 

        //Add test data.

        Account a = new account (name='Test Account');

        insert a;

       

        Contact t = new contact (lastname='Test Contact', accountid=a.id);

        insert t;

       

        Campaign c = new campaign (name='Test Campaign');

        insert c;

       

        Opportunity o = new opportunity (name='Test Donation', campaignid=c.id, accountid=a.id);

        insert o;

       

        OpportunityContactRole[] ocr = new OpportunityContactRole[]{};

               for(Integer i = 1; i < 11; i++){

                       OpportunityContactRole r = new OpportunityContactRole (opportunityid=o.id, contactid = t.id);

                       ocr.add(r);

               }

 

        // Instantiate a new controller  - This where we get the error.

        OpportunityContactController controller = new OpportunityContactController();

 

        controller.queryRole();

        List<OpportunityContactRole> ocrs = controller.getroles();

        System.assertEquals(10,ocrs.size());

       

    }

}

 

I have tried several different iterations of the extension class and the test but cannot seem to find one that works, any ideas?

 

Thanks.

I apologize for this seemingly naive question, but is there a concise listing of APEX commands, their attributes, syntax, etc? We have been trying for several days to find things like available attributes for the InputField command and a broader list of APEX commands in general. Any help would be greatly appreciated. Thanks, Mike

I have installed and  configured force IDE in  eclipse  Helios. when i try to create a project, after entering login detials  in the progress information box it shows  fetching packages it displays for a while at the end  "connection time out " error is coming up  all the time.

  • June 29, 2011
  • Like
  • 0

Hello,

 

I have 2 problems and I would really apreciate some help here.

 

1. I have a 'company' object and a 'contacts' object (both of them are custom made). They are related objects with lookup fields. From the contact I have the posibility to select a company. When I move the mouse over the company name, a rollover windows appears (i'm not sure if this is the correct name). See the attachment. There I see my company name. Is there any way to have other informations in that rollover window ? For example I would like to see the address details of that company.

 

2. In my custom 'Contacts' object i defined 'first name' and 'last name' fields. In the standard 'Contacts' object i saw that there is a field called 'Name' which includes the first name and the last name. How can i make a custom field called name that concatenates my custom 'first name' and 'last name' fields ?

 

Thanks