1

Below is my Apex Page:

<apex:page standardController="Process_Adherence_Monitoring__c" extensions="PAM_QuestionButtonPageController">

<apex:form >
<apex:pageMessages id="msg"/>
 <!-- Case Section  --> 
   <apex:pageBlock title="New Case">
    <apex:pageBlockButtons >
     <apex:commandButton action="{!save}" value="Save"/>
     <apex:commandButton value="Cancel" action="{!Cancel}"/>
    </apex:pageBlockButtons>
 <apex:pageBlockSection title="Case Information"  collapsible="false"> 
   <apex:repeat value="{!ccLIst}" var="cc"> 
     <apex:outputfield label="Organization Name" value="{!cc.Accountid}"/>
     <apex:inputfield value="{!cc.Contactid}"/>
     <apex:inputfield value="{!cc.Status}"/>
     <apex:inputfield value="{!cc.Invalid_Request__c}"/>
     <apex:outputfield value="{!cc.Reason}"/> 
     <apex:inputfield value="{!cc.Invalid_FTR__c}"/>
     <apex:outputfield value="{!cc.Subcategories__c}"/>
     <apex:inputfield value="{!cc.Invalid_Detail__c}"/>
     <apex:inputfield value="{!cc.Priority}"/>
     <apex:inputfield value="{!cc.Turn_Off_Auto_response__c}"/>
     <apex:inputfield value="{!cc.Privileged__c}"/>
     <apex:inputfield value="{!cc.Bus_Dev__c}"/>
     <apex:inputfield value="{!cc.Origin}"/>
     <apex:inputfield value="{!cc.Type}"/>
     <apex:inputfield value="{!cc.OwnerId}"/>
     <apex:inputfield value="{!cc.ParentId}"/>
   </apex:repeat>
  </apex:pageBlockSection> 
 <apex:pageBlockSection title="Case Outcome"  columns="1"> 
    <apex:repeat value="{!ccLIst}" var="cc"> 
     <apex:inputfield value="{!cc.Outcome_FTR__c}"/>  
     <apex:inputfield value="{!cc.Outcome_Description__c}"/>
    </apex:repeat> 
 </apex:pageBlockSection>  
  <apex:pageBlockSection title="Case Details"  columns="1"> 
    <apex:repeat value="{!ccLIst}" var="cc"> 
     <apex:inputfield label="Question Short Description" value="{!cc.Subject}"/>
     <apex:inputfield label="Question Details" value="{!cc.Description}"/>
    </apex:repeat> 
 </apex:pageBlockSection>  
  <apex:pageBlockSection title="System Information"  columns="1" collapsible = "false"> 
    <apex:repeat value="{!ccLIst}" var="cc"> 
     <apex:outputfield value="{!cc.Process_Adherence_Monitoring__c}"/>
     <apex:outputfield value="{!cc.RecordTypeId}"/>
    </apex:repeat> 
 </apex:pageBlockSection>  
</apex:pageBlock>
</apex:form>
</apex:page>

Below is my Apex Class:

public with sharing class PAM_QuestionButtonPageController {

    List<Case> CaseList = new List<Case>();
    List<Case> CasetoDisplay = new List<Case>();
    public boolean showCase{get;set;}


    public PAM_QuestionButtonPageController(ApexPages.StandardController controller) {
         Map<String,Schema.RecordTypeInfo> rtMap = Schema.SObjectType.Case.getRecordTypeInfosByName();
         Id rtLeadID =  rtMap.get('Operations - PAM').getRecordTypeId(); 
        Id pageId = ApexPages.currentPage().getParameters().get('id');
        Process_Adherence_Monitoring__c[] PAMList = [select id,Account_Number__c,Organization_Name__c  from Process_Adherence_Monitoring__c where id =: pageId];

        String sCase = ApexPages.currentPage().getParameters().get('showCC');
        system.debug('sCase-->'+sCase);
        if(sCase == '1')
        {
            showCase = true;
            system.debug('showCase-->>'+showCase);
        }

        CaseList = [Select id,Reason,Subcategories__c,Accountid,OwnerId,RecordTypeId FROM Case WHERE Process_Adherence_Monitoring__c =: pageId limit 1];

        if(CaseList.size() == 0 || CaseList.size() > 0)
        {
        Case c = new Case();
        c.AccountId  = PAMList[0].Organization_Name__c;
        c.Reason = 'Process Adherence Monitoring (PAM)';
        c.Subcategories__c = 'FRB';
        c.RecordTypeId = rtLeadID;
        c.Process_Adherence_Monitoring__c = PAMList[0].Id;
        CasetoDisplay.add(c);
        }
     }
   public list<Case> getccLIst(){
       if(CasetoDisplay.size() >0){
         return CasetoDisplay;
       }
       return null;
   }
   public PageReference save()
   {         
      try{
           if(CasetoDisplay.size() <> null){
             insert CasetoDisplay;
             return new PageReference('/'+CasetoDisplay[0].id);
           }

       }
       catch(Exception ex){
          ApexPages.addMessages(ex);
       }
          return null;

   }   
}

I am opening custom case layout from a button on Process Adherence Monitoring object but I am not able to refer Case "Internal Comments" field because I cannot see it in the schema of Case Objects.How do I refer the Internal Comments field in the VisualForce Page?

1

Internal Comments is not really a field, however, it looks like a field on case standard layout. The information entered in this field is actually stored in the CaseComment object which is related to the case.

What I would suggest is that, you put the field as a Large Text Area on your VF, and then handle the data in your Apex controller and insert the record in CaseComment object right after inserting/updating your case data, because that will give you the ID of case record to be used while inserting case comment record.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.