• Punam Agrawalla
  • NEWBIE
  • 0 Points
  • Member since 2014

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

As I am trying to Display message in the apex code:
for if condition is true

ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,cw.cat.name));

Hello! I have the following Apex Class that is designed to allow attachments to upload via a VF page. I know I have to be missing something really obvious, but I can't get the VF page to show up in my Page Layout so that I can deploy it to users. The VF page should appear on the custom object "Install_Note__c". Any ideas?

- - - - -  

public class AttachmentUploadController {

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

  public PageReference upload() {

    attachment.OwnerId = UserInfo.getUserId();
    attachment.ParentId = '01I700000007zWH'; // 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'));
    return null;
  }

}
- - - - -

And then this is the VF Page: 
- - - - - 
<apex:page controller="AttachmentUploadController">
  <apex:sectionHeader title="Visualforce Example" subtitle="Install Note Photos"/>

  <apex:form enctype="multipart/form-data">
    <apex:pageMessages />
    <apex:pageBlock title="Install Note Photos">

      <apex:pageBlockButtons >
        <apex:commandButton action="{!upload}" value="Save"/>
      </apex:pageBlockButtons>

      <apex:pageBlockSection showHeader="false" columns="2" id="block1">

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Antenna Connections" for="fileName"/>
          <apex:inputText value="{!attachment.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Browse" for="file"/>
          <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
        </apex:pageBlockSectionItem>

          <apex:pageBlockSectionItem >
          <apex:outputLabel value="Modem Connenections" for="fileName"/>
          <apex:inputText value="{!attachment.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Browse" for="file"/>
          <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
        </apex:pageBlockSectionItem>
        
         <apex:pageBlockSectionItem >
          <apex:outputLabel value="Antenna Perspective" for="fileName"/>
          <apex:inputText value="{!attachment.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Browse" for="file"/>
          <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
        </apex:pageBlockSectionItem>
       
        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Cable Run" for="fileName"/>
          <apex:inputText value="{!attachment.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Browse" for="file"/>
          <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
        </apex:pageBlockSectionItem>
        
         <apex:pageBlockSectionItem >
          <apex:outputLabel value="Additional" for="fileName"/>
          <apex:inputText value="{!attachment.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Browse" for="file"/>
          <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
        </apex:pageBlockSectionItem>
        
         <apex:pageBlockSectionItem >
          <apex:outputLabel value="Additional" for="fileName"/>
          <apex:inputText value="{!attachment.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Browse" for="file"/>
          <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
        </apex:pageBlockSectionItem>
        
      </apex:pageBlockSection>

    </apex:pageBlock>
  </apex:form>
</apex:page>


Given a field name 'Geolocation__c' of type Geolocation, the following code produces 'System.TypeException: Data type not supported':
SObject contactSob = new Contact();
System.debug(contactSob.get('Geolocation__c'));
This seems to have broken a lot of our code. Any ideas what's causing this, or a workaround?

I have a picklist called Status, displayed in a Visualforce table with fields like ..

Closed
Open
Critical
How can make all fields GREEN except the ones that are Critical RED? I have tried this code so far... 

<style>
.errorClass {
    background-color: red;
}
.normalClass {
    background-color: green;
}
</style>
=================================
<apex:pageBlock>
    <apex:pageBlockTable value="{!fb}" var="item">
        <apex:column value="{!item.name}"
                     styleClass="{!IF(item.status__c == 'Critical','errorClass','normalClass')}"/>
        <apex:column value="{!item.status__c}"
                     styleClass="{!IF(item.status__c == 'Critical','errorClass','normalClass')}"/>
    </apex:pageBlockTable>
</apex:pageBlock>
=================================
public class dataTableCon {
    List<Feedback__c> fb;
     public List<Feedback__c> getAccounts() {
        if(fb== null) fb= [select Name, Description__c, Importance__c, Resolution__c, Status__c,Owner.name from Feedback__c];
        return fb;
    }
}
=================================
ERROR..
Error: Formula expression is required for attribute value in <apex:pageBlockTable> in vf_table at line 49 column 56
  • April 16, 2014
  • Like
  • 0