• Melissa Howard
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 6
    Replies
Hi,

I have a custom object called A with a lookup relationship (not master/detail) with custom object b. I can't use a roll up but I need to count how many B records for each A record and then just set a field on A with that number. This should be simple to do but I am missing some steps. How to set this up (I need apex code so I have a starting point)?

TIA,
Hi,

I want to do a lookup based on 3 contact input fields in the VF page. So, I created variables in the VF that the APEX controller can use in it's SELECT statement. But, the variables created in the VF page give an error.

Here is the APEX:

public with sharing class ContactExtendedController2 {

    public Contact contactSetting{get;set;}

    public ContactExtendedController2(ApexPages.StandardController Contact) {
        contactSetting=new Contact();
        contactSetting = [SELECT Id, Name FROM Contact
            WHERE FirstName = firstname AND LastName = lastname]; // AND LastName = lastName];
                               // WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }      
 
The error in compiling this code is:
Error: Compile Error: expecting a colon, found 'firstname' at line 8 column 30  

Here is the VF, which saves and previews fine,  that sets the firstName and lastName variables that I want to use in the APEX


					
<apex:page standardController="Contact" extensions="ContactExtendedController2">

    <apex:form >
        <apex:pageBlock title="Foodbank of Santa Barbara County Volunteer Information">
            <apex:pageBlockSection columns="1">
                <!-- <b>Input Date  :</b><apex:inputfield value="TODAY"/> This gives error, even if value="7/21/2014" -->
                <apex:outputLabel value="Lookup Contact" for="ContactLookup"/>
                <apex:inputField id="RequestedBy" value="{!contactSetting.Name}" />
                <apex:inputField value="{!Contact.FirstName}"/> 
                <apex:inputField value="{!Contact.LastName}"/> 
                <apex:inputField value="{!Contact.Email}"/> 
                
                    <apex:variable var="firstName" value="{!Contact.FirstName}" />
                    <apex:variable var="lastName" value="{!Contact.LastName}" />
         
   
I have an extended controller for the Contact object that is not being picked up by Visualforce.

The VF line that isn't working is the which I want to be a lookup field is:

                <apex:inputField id="RequestedBy" value="{!contactSetting}" />
                 Error =
Error: Could not resolve the entity from <apex:inputField> value binding '{!contactSetting}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.  

    <apex:form >
        <apex:pageBlock title="Foodbank of Santa Barbara County Volunteer Information">
            <apex:pageBlockSection columns="1">
                <!-- <b>Input Date  :</b><apex:inputfield value="TODAY"/> This gives error, even if value="7/21/2014"
                <apex:outputLabel value="Lookup Contact" for="ContactLookup"/
                <apex:inputField id="RequestedBy" value="{!contactSetting}" />

The APEX is:

public with sharing class ContactExtendedController {

    public Contact contactSetting{get;set;}

    public ContactExtendedController(ApexPages.StandardController Contact) {
        contactSetting=new Contact();
    }
   
    public ContactExtendedController() {
        contactSetting = [SELECT Id, Name FROM Contact
                   WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
        // if (contactSetting == null)
        //    System.debug('Contact Doesn't Exist. Contact the Foodbank.');
    }
}
I have the following APEX class:

public class ContactExtendedController {
     
       public List<Contact> getContacts() {
            return [SELECT Id, Name, Phone, Email
                FROM Contact
                ORDER BY LastModifiedDate DESC LIMIT 10];
       }
        // Get the 'id' query parameter from the URL of the page.
        // If it's not specified, return an empty contact.
        // Otherwise, issue a SOQL query to return the contact from the
        // database
        
        public Contact getContact() {
        Id id = System.currentPageReference().getParameters().get('id');
        return id == null ? new Contact() : [SELECT Id, Name
            FROM Contact
            WHERE Id = :id];
        }
    
}


And this opening to my VF page errors:

<apex:page standardController="Contact" extensions="ContactExtendedController">

with error: Error: Unknown constructor 'ContactExtendedController.ContactExtendedController(ApexPages.StandardController controller)'


This seems so simple a thing. I can't understand why the "extensions" clause isn't working.

Thanks much,

Evan
I have the following APEX class:

public class ContactExtendedController {
     
       public List<Contact> getContacts() {
            return [SELECT Id, Name, Phone, Email
                FROM Contact
                ORDER BY LastModifiedDate DESC LIMIT 10];
       }
        // Get the 'id' query parameter from the URL of the page.
        // If it's not specified, return an empty contact.
        // Otherwise, issue a SOQL query to return the contact from the
        // database
        
        public Contact getContact() {
        Id id = System.currentPageReference().getParameters().get('id');
        return id == null ? new Contact() : [SELECT Id, Name
            FROM Contact
            WHERE Id = :id];
        }
    
}


And this opening to my VF page errors:

<apex:page standardController="Contact" extensions="ContactExtendedController">

with error: Error: Unknown constructor 'ContactExtendedController.ContactExtendedController(ApexPages.StandardController controller)'


This seems so simple a thing. I can't understand why the "extensions" clause isn't working.

Thanks much,

Evan

Hi everyone, 

could you tell me how to set the guest user's permissions or site's permissions, so that a guest user will be able to read the standard fields(such as firstName, LastName, TItle, etc.) of the object User?