• Krishna Ganesan 12
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hello - Can someone please advise on this error ? Have a simple VF page with Contact Name , Email, Contact Phone and Desctiption, Attachment. Trying to include two picklist fields Product__c(controlling) and Reason_for_inquiry__c which is the dependent. 

Controller - CcWebToCase ( Added Product and Reason for Inquiry)

public without sharing class CcWebToCase {

    public CcWebToCase() {

    }


    public CcWebToCase(ApexPages.StandardController controller) {

    }


    public String getCase() {
        return null;
    }


  public String contactName {get; set;}
  public String contactEmail {get; set;}
  public String contactPhone {get; set;}
  public String description {get; set;}
  public String Product {get; set;}
  public String Reason_For_Inquiry {get; set;}


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

  public PageReference upload() {


    // first we need to create the case

    Case web2case = new Case();

    web2case.Origin = 'Web';
    web2case.Type = 'Customer Support';
    web2case.RecordTypeId = '012F00000013Q45';
    web2case.Originating_Site__c = '00NF000000CyB8X';

    if (contactName != null) web2case.SuppliedName = contactName;
    if (contactEmail != null) web2case.SuppliedEmail = contactEmail;
    if (contactPhone != null) web2case.SuppliedPhone = contactPhone;
    if (description != null) web2case.Description = description;
    if (Product != null) web2case.Product__c = Product;
    if (Reason_For_Inquiry != null) web2case.Reason_For_Inquiry__c = Reason_For_Inquiry;


    //this will check to see if there is an existing contact with the email

    List<Contact> existingContact = new List<Contact>();

    if (contactEmail != null) {
       existingContact = [Select Id, AccountId From Contact Where Email = :contactEmail LIMIT 1];
    }

    if (existingContact.size() != 0) {
      web2case.ContactId = existingContact[0].Id;
      web2case.AccountId = existingContact[0].AccountId;
    }




    try {
        insert web2case;
    } catch (DMLException e) {
        ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error inserting case'));
        return null;    
    }

    if (attachment.body != null) {


    attachment.OwnerId = UserInfo.getUserId();
    attachment.ParentId = web2case.Id; // the record the file is attached to
    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'));
    PageReference thankYouPage = new PageReference('http://closing.force.com/ClientSupportThankYou');
    thankYouPage.setRedirect(true);
    return thankYouPage;
  }

}


VF Page - Trying to include the controlling field and get the error  "    Error: Could not resolve the entity from <apex:inputField> value binding '{!Case.Product__c}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable"


  <apex:pageBlockSectionItem >
                  <apex:outputLabel value=""></apex:outputLabel>
                  <apex:outputLabel value="Email" for="email" style="width:150px"></apex:outputLabel>
                </apex:pageBlockSectionItem> 
                                 
                <apex:pageBlockSectionItem >
                  <apex:outputLabel value=""></apex:outputLabel>                  
                  <apex:inputText value="{!contactEmail}" id="contactEmail" required="true"/>
                </apex:pageBlockSectionItem>

                <br/>
                
                <apex:pageBlockSectionItem >
                          <apex:outputLabel value=""></apex:outputLabel>
                          <apex:outputLabel value="Contact Phone" for="contactPhone"></apex:outputLabel>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                   <apex:outputLabel value=""></apex:outputLabel>
                   <apex:inputText value="{!contactPhone}" id="contactPhone"/>
                </apex:pageBlockSectionItem>
                
                <br/>
                        <apex:pageBlockSectionItem >
                          <apex:outputLabel value=""></apex:outputLabel>
                          <apex:outputLabel value="Description" for="description"></apex:outputLabel>
                        </apex:pageBlockSectionItem>
                        <apex:pageBlockSectionItem >
                          <apex:outputLabel value=""></apex:outputLabel>
                          <apex:inputTextarea value="{!description}" id="description" rows="10" cols="50"/>
                        </apex:pageBlockSectionItem>
                <br/>


<apex:pageBlockSectionItem >
<apex:outputLabel value=""></apex:outputLabel>
<apex:inputField value="{!Case.Product__c}" required="false"/>
</apex:pageBlockSectionItem>


<br/>
Hi all,
When custom button in detail page of  custom object is clicked i'm generating the PDF . I want to send the generated PDF as email. Can  we do this...?
Can anyone help me over here.

Thanks in advance.