• Manpreet Singh 13
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 11
    Replies
Dear All,

I have a custom field 'Action'. It is a Long Text Area type of field. When i try to bring this field on to the visualforce page then it does not retain formatting like line spacing, line breaks etc.. Below mentioned is the code, please let me know how formatting can be retained on visualforce page as well.

 '</br>*****<h1>POS</h1>*****' +
    '</br></br>' +
    '<tr align="left"><b>POS Number: </b></tr>' + POS.Name + '</br></br>' +
    '<tr align="left"><b>Created By: </b></tr>' + POS.CreatedBy.name + '</br></br>'+
    '<tr align="left"><b>Is this the most recent POS? </b></tr>' + POS.Most_Recent_Record__c + '</br></br>'+
     '<tr align="left"><b>Status: </b></tr>' + POS.Status__c + '</br></br>'+
    '<tr align="left"><b>Action: </b></tr>' + '<div style="word-wrap:break-word; width:450px;"/>' + POS.Action__c + '</br>';
    containerList.add(cc);

Date Entered in Salesforce.com
User-added image
Formatting on Visualforce page is all broken

User-added image


Thanks.
Hello All,

How can i reduce the width of my output text. It is a standard Comments (Text) field from Tasks. Any inputs/pointers will be appreciated

Here is the code

for(Task task: gettask())
{
    CommonContainer cc=new CommonContainer();
    cc.createdDate=task.CreatedDate;
    cc.content=
    '</br>*****<h1>Tasks and Activities</h1>*****' +
    '</br></br>' +
    '<tr align="left"><b>Assigned: </b></tr>' + task.Owner.name + '</br></br>' +
    '<tr align="left"><b>Created By: </b></tr>' + task.CreatedBy.name + '</br></br>'+
    '<tr align="left"><b>Status: </b></tr>' + task.Status + '</br></br>'+
    '<tr align="left"><b>Priority: </b></tr>' + task.Priority + '</br></br>'+
    '<tr align="left"><b>Due Date: </b></tr>' + task.ActivityDate + '</br></br>'+
    '<tr align="left"><b>Subject: </b></tr>' + task.Subject + '</br></br>' +
    '<tr align="left"><b>Description/Comment: </b></tr>' + task.Description +'</br>';
     containerList.add(cc); 
}

Here is the output of the code, you can see text is spread across the page. I want it to be little compact (probably half the current size)

User-added image
Created Apex class to show Case Tasks and Case Emails in chronological order on visualforce page. The problem is that I am not able to show fields on visualforce page, not sure where I am going wrong. Any help/pointers would be appreciated

Here is the Apex Class code

global with sharing class CaseEmailExtension {

  private final Case currentCase;

 public CaseEmailExtension(ApexPages.StandardController currentcase) {
    this.currentCase = (Case)currentcase.getRecord();
  }
  
    global class commoncontainer implements Comparable {

    public DateTime createdDate{get;set;}

    public String content{get;set;}
    
    global Integer compareTo(Object compareTo) {
        commoncontainer compareToEmp = (commoncontainer)compareTo;
        if (createddate== compareToEmp.createddate) return 0;
        if (createddate> compareToEmp.createddate) return 1;
        return -1;        
    }
  }

  public List<commoncontainer> getSortcommoncontainer(){
    List <commoncontainer> containerlist = new List<commoncontainer>();
    
    for(EmailMessage emailmsg : getsortEmails())
{
    CommonContainer cc=new CommonContainer();
    cc.createdDate=emailmsg.CreatedDate;
    cc.content='Subject:' + emailmsg.CreatedDate + 'From:' + emailmsg.FromAddress + 'To:' + emailmsg.ToAddress + 'BCC:' + emailmsg.BCCAddress + 'Subject:' + emailmsg.Subject + 'EmailBody:' + emailmsg.TextBody + 'CreatedBy:' + emailmsg.CreatedBy.Name;
    containerList.add(cc);
}

    for(Attachment att: getattachments())
{
    CommonContainer cc=new CommonContainer();
    cc.createdDate=att.CreatedDate;
    cc.content='Name:' + att.Name + 'Created By:' + att.CreatedBy.name;
    containerList.add(cc);
}

    for(Task task: gettask())
{
    CommonContainer cc=new CommonContainer();
    cc.createdDate=task.CreatedDate;
    cc.content='Assigned To:' + task.Who.Name + 'Created By:' + task.CreatedBy.name + 'Status:' + task.Status + 'Priority:' + task.Priority + 'Due Date:' + task.ActivityDate + 'Subject:' + task.Subject + 'Description' + task.Description;
    containerList.add(cc);
}
containerlist.sort(); 
   return containerlist; 
  }

public List<EmailMessage> getSortEmails(){
    List <EmailMessage> sortedEmails = new List<EmailMessage>();
    sortedEmails = [SELECT Id, FromAddress, ToAddress, BCCAddress, CreatedDate, Subject, HasAttachment, Incoming, TextBody, CreatedBy.Name  
            from EmailMessage where ParentId =: currentCase.Id 
            order by MessageDate DESC ];
    return sortedEmails;
  }

public List<Task> getTask() {
    List<Task> Task= new List<Task>();
    Task = [SELECT Id, Priority, Subject, Status, Description, CreatedDate, ActivityDate, CreatedBy.Name,Who.Name
            from Task order by CreatedDate DESC]; 
    return Task;  
  }
}

Here is the Visualforce Page code

<apex:page standardController="Case" showHeader="false" sidebar="false" title="Case Number: {!Case.CaseNumber}" extensions="CaseEmailExtension">
<apex:form >
<apex:pageBlock title="Case Number: {!Case.CaseNumber}">

<apex:pageBlockButtons location="top" >
            <apex:CommandButton value="Print" onclick="javascript:window.print(); return false"/>
            <apex:CommandButton value="Close" onclick="window.close(); return false;"/>
    </apex:pageBlockButtons>

<apex:repeat value="{!sortCommonContainer}" var="cc">

    <apex:pageblock >
    <apex:facet name="header">
        <apex:outputText value="{0,date,dd'.'MM'.'yyyy HH:mm:ss z}" style="font-weight:bold;font-style:italic;font-size:12px;float:left ">
        <apex:param value="{!cc.CreatedDate}" />
        </apex:outputText>
        </apex:facet>
        <td width="100%" align="left">
            <table cellpadding="2px">
                <tr>
                                                
                </tr>
            </table>
        </td>
                
          
        </apex:pageblock>
</apex:repeat>
</apex:form>
</apex:page>
Dear All,

I have created a visualforce page wherein I am getting all Tasks and Email records from the Case. I am showing them in the chronological order.

I have created another component (not working and need help) on Visualforce page which allow users to either select Tasks or Emails and then click on 'Show' button. Depending on the selection on visualforce page, user would either see Tasks or Emails on the visualforce page. Any help/pointers would help alot.

Related List Selection

*************************************Here is the code of my controller********************************************

public with sharing class CaseEmailExtension {

  private final Case currentCase;


  public CaseEmailExtension(ApexPages.StandardController currentcase) {
    this.currentCase = (Case)currentcase.getRecord();
  }

  public List<EmailMessage> getSortEmails(){
    List <EmailMessage> sortedEmails = new List<EmailMessage>();
    sortedEmails = [SELECT Id, FromAddress, ToAddress, BCCAddress, MessageDate, Subject, HasAttachment, Incoming, TextBody, CreatedBy.Name  
            from EmailMessage where ParentId =: currentCase.Id 
            order by MessageDate DESC ];
    return sortedEmails;
  }

  public List<Task> getTask() {
    List<Task> Task= new List<Task>();
    Task = [SELECT Id, Priority, Subject, Status, Description, CreatedDate, ActivityDate, CreatedBy.Name,Who.Name
            from Task order by CreatedDate DESC]; 
    return Task;  
  }

}


********************************Here is Visualforce Page code*****************************

</apex:pageBlock>

<apex:pageblock >

<apex:pageBlockSection id="RelatedList" columns="2" title="Related List Selection" collapsible="true">
      
                                   
                <apex:selectcheckboxes layout="pageDirection">
                        
                    <apex:selectOption itemLabel="Tasks and Activities" itemValue="Tasks"/>
                    <apex:selectOption itemLabel="Emails" itemValue="EMAIL"/>
                             
                </apex:selectcheckboxes>
                
                               
          <apex:outputPanel layout="none">
          <apex:commandButton value="Show" />
          </apex:outputPanel>
                                     
     </apex:pageBlockSection>

</apex:pageBlock>
Dear All,

I am creating a visualforce page which would basically capture case related updates (excluding field updates) including Tasks created, Emails Sent, Email recieved , Comments created, custom related lists in chronological fashion on Visualforce page. Any pointers would be appreciated. Thanks.
Hello All,

I have written below mentioned code and I am getting "Error: Invalid field Testing__r for SObject Case".

Please note, 'Testing' is a custom object and is related list of Case object

<apex:pageBlockSection id="Testing" columns="1" title="Testing" collapsible="true">
      <apex:pageBlockTable value="{!Case.Testing__r}" var="item">
      <apex:column value="{!item.Name__c}"/>
      
      </apex:pageBlockTable>
      
      </apex:pageBlockSection>
Dear All,

I am stuck with building 'Print View'. I have brought all the necessary fields on custom visualforce page but need help with bringing related lists fields like print view. I am trying below code but it shows everything in tabular format and all activities (Open and Closed). I want separate section for open and closed activities. I am using standard case controller. Any input would be appreciated. Thank you.

<apex:pageBlockSection id="OpenActivites" columns="1" title="Activities" collapsible="true">
      <apex:pageBlockTable value="{!Case.Tasks}" var="item">
      <apex:column value="{!item.Subject}"/>
      <apex:column value="{!item.ActivityDate}"/>
      <apex:column value="{!item.OwnerId}"/>
      <apex:column value="{!item.Description}"/>
      <apex:column value="{!item.Status}"/>
      <apex:column value="{!item.CreatedById}"/>
      <apex:column value="{!item.CreatedDate}"/>
      </apex:pageBlockTable>
      
      </apex:pageBlockSection>
Dear All,

I am creating a visualforce page which opens when we click on a 'Custom' button (/apex/CaseDetail?CaseId={!Case.Id}) placed on Case detail page. I am not able to pass the Account Name of the record into this custom page. 

Below mentioned is the code - I am sure there is some issue with the code..

<apex:page showHeader="false" sidebar="false" standardController="Case">
  <apex:form >
    <apex:pageBlock title="Case Details" mode="maindetail">
    
    <apex:pageBlockButtons location="top">
            <apex:CommandButton value="Print" onclick="javascript:window.print(); return false"/>
            <apex:CommandButton value="Close" onclick="window.close(); return false;"/>
    </apex:pageBlockButtons>
    
    <apex:pageBlockSection id="CaseSumary" columns="3" title="Case Summary" collapsible="true">
          
          <apex:pageBlockSectionItem >
          <apex:outputPanel >
                   <apex:outputLabel value="Account Name:" for="account"/>
                   <apex:outputField id="type" value="{!Case.AccountId}"/>
          </apex:outputPanel> 
          </apex:pageBlockSectionItem>
                                          
     </apex:pageBlockSection>
      
    </apex:pageBlock>
  </apex:form>
</apex:page>


And here is the screenshot of visual force page. You can see that I am not able to get value of the account record.

User-added image

Thanks,
Manpreet Singh
Created Apex class to show Case Tasks and Case Emails in chronological order on visualforce page. The problem is that I am not able to show fields on visualforce page, not sure where I am going wrong. Any help/pointers would be appreciated

Here is the Apex Class code

global with sharing class CaseEmailExtension {

  private final Case currentCase;

 public CaseEmailExtension(ApexPages.StandardController currentcase) {
    this.currentCase = (Case)currentcase.getRecord();
  }
  
    global class commoncontainer implements Comparable {

    public DateTime createdDate{get;set;}

    public String content{get;set;}
    
    global Integer compareTo(Object compareTo) {
        commoncontainer compareToEmp = (commoncontainer)compareTo;
        if (createddate== compareToEmp.createddate) return 0;
        if (createddate> compareToEmp.createddate) return 1;
        return -1;        
    }
  }

  public List<commoncontainer> getSortcommoncontainer(){
    List <commoncontainer> containerlist = new List<commoncontainer>();
    
    for(EmailMessage emailmsg : getsortEmails())
{
    CommonContainer cc=new CommonContainer();
    cc.createdDate=emailmsg.CreatedDate;
    cc.content='Subject:' + emailmsg.CreatedDate + 'From:' + emailmsg.FromAddress + 'To:' + emailmsg.ToAddress + 'BCC:' + emailmsg.BCCAddress + 'Subject:' + emailmsg.Subject + 'EmailBody:' + emailmsg.TextBody + 'CreatedBy:' + emailmsg.CreatedBy.Name;
    containerList.add(cc);
}

    for(Attachment att: getattachments())
{
    CommonContainer cc=new CommonContainer();
    cc.createdDate=att.CreatedDate;
    cc.content='Name:' + att.Name + 'Created By:' + att.CreatedBy.name;
    containerList.add(cc);
}

    for(Task task: gettask())
{
    CommonContainer cc=new CommonContainer();
    cc.createdDate=task.CreatedDate;
    cc.content='Assigned To:' + task.Who.Name + 'Created By:' + task.CreatedBy.name + 'Status:' + task.Status + 'Priority:' + task.Priority + 'Due Date:' + task.ActivityDate + 'Subject:' + task.Subject + 'Description' + task.Description;
    containerList.add(cc);
}
containerlist.sort(); 
   return containerlist; 
  }

public List<EmailMessage> getSortEmails(){
    List <EmailMessage> sortedEmails = new List<EmailMessage>();
    sortedEmails = [SELECT Id, FromAddress, ToAddress, BCCAddress, CreatedDate, Subject, HasAttachment, Incoming, TextBody, CreatedBy.Name  
            from EmailMessage where ParentId =: currentCase.Id 
            order by MessageDate DESC ];
    return sortedEmails;
  }

public List<Task> getTask() {
    List<Task> Task= new List<Task>();
    Task = [SELECT Id, Priority, Subject, Status, Description, CreatedDate, ActivityDate, CreatedBy.Name,Who.Name
            from Task order by CreatedDate DESC]; 
    return Task;  
  }
}

Here is the Visualforce Page code

<apex:page standardController="Case" showHeader="false" sidebar="false" title="Case Number: {!Case.CaseNumber}" extensions="CaseEmailExtension">
<apex:form >
<apex:pageBlock title="Case Number: {!Case.CaseNumber}">

<apex:pageBlockButtons location="top" >
            <apex:CommandButton value="Print" onclick="javascript:window.print(); return false"/>
            <apex:CommandButton value="Close" onclick="window.close(); return false;"/>
    </apex:pageBlockButtons>

<apex:repeat value="{!sortCommonContainer}" var="cc">

    <apex:pageblock >
    <apex:facet name="header">
        <apex:outputText value="{0,date,dd'.'MM'.'yyyy HH:mm:ss z}" style="font-weight:bold;font-style:italic;font-size:12px;float:left ">
        <apex:param value="{!cc.CreatedDate}" />
        </apex:outputText>
        </apex:facet>
        <td width="100%" align="left">
            <table cellpadding="2px">
                <tr>
                                                
                </tr>
            </table>
        </td>
                
          
        </apex:pageblock>
</apex:repeat>
</apex:form>
</apex:page>
I'm looking for a nonprofit salesforce expert to hire to customize our database- need some customized fiields and more training to mazimize usage.  Anyone in the Dallas Ft. Worth Area? 
Hello All,

How can i reduce the width of my output text. It is a standard Comments (Text) field from Tasks. Any inputs/pointers will be appreciated

Here is the code

for(Task task: gettask())
{
    CommonContainer cc=new CommonContainer();
    cc.createdDate=task.CreatedDate;
    cc.content=
    '</br>*****<h1>Tasks and Activities</h1>*****' +
    '</br></br>' +
    '<tr align="left"><b>Assigned: </b></tr>' + task.Owner.name + '</br></br>' +
    '<tr align="left"><b>Created By: </b></tr>' + task.CreatedBy.name + '</br></br>'+
    '<tr align="left"><b>Status: </b></tr>' + task.Status + '</br></br>'+
    '<tr align="left"><b>Priority: </b></tr>' + task.Priority + '</br></br>'+
    '<tr align="left"><b>Due Date: </b></tr>' + task.ActivityDate + '</br></br>'+
    '<tr align="left"><b>Subject: </b></tr>' + task.Subject + '</br></br>' +
    '<tr align="left"><b>Description/Comment: </b></tr>' + task.Description +'</br>';
     containerList.add(cc); 
}

Here is the output of the code, you can see text is spread across the page. I want it to be little compact (probably half the current size)

User-added image
Created Apex class to show Case Tasks and Case Emails in chronological order on visualforce page. The problem is that I am not able to show fields on visualforce page, not sure where I am going wrong. Any help/pointers would be appreciated

Here is the Apex Class code

global with sharing class CaseEmailExtension {

  private final Case currentCase;

 public CaseEmailExtension(ApexPages.StandardController currentcase) {
    this.currentCase = (Case)currentcase.getRecord();
  }
  
    global class commoncontainer implements Comparable {

    public DateTime createdDate{get;set;}

    public String content{get;set;}
    
    global Integer compareTo(Object compareTo) {
        commoncontainer compareToEmp = (commoncontainer)compareTo;
        if (createddate== compareToEmp.createddate) return 0;
        if (createddate> compareToEmp.createddate) return 1;
        return -1;        
    }
  }

  public List<commoncontainer> getSortcommoncontainer(){
    List <commoncontainer> containerlist = new List<commoncontainer>();
    
    for(EmailMessage emailmsg : getsortEmails())
{
    CommonContainer cc=new CommonContainer();
    cc.createdDate=emailmsg.CreatedDate;
    cc.content='Subject:' + emailmsg.CreatedDate + 'From:' + emailmsg.FromAddress + 'To:' + emailmsg.ToAddress + 'BCC:' + emailmsg.BCCAddress + 'Subject:' + emailmsg.Subject + 'EmailBody:' + emailmsg.TextBody + 'CreatedBy:' + emailmsg.CreatedBy.Name;
    containerList.add(cc);
}

    for(Attachment att: getattachments())
{
    CommonContainer cc=new CommonContainer();
    cc.createdDate=att.CreatedDate;
    cc.content='Name:' + att.Name + 'Created By:' + att.CreatedBy.name;
    containerList.add(cc);
}

    for(Task task: gettask())
{
    CommonContainer cc=new CommonContainer();
    cc.createdDate=task.CreatedDate;
    cc.content='Assigned To:' + task.Who.Name + 'Created By:' + task.CreatedBy.name + 'Status:' + task.Status + 'Priority:' + task.Priority + 'Due Date:' + task.ActivityDate + 'Subject:' + task.Subject + 'Description' + task.Description;
    containerList.add(cc);
}
containerlist.sort(); 
   return containerlist; 
  }

public List<EmailMessage> getSortEmails(){
    List <EmailMessage> sortedEmails = new List<EmailMessage>();
    sortedEmails = [SELECT Id, FromAddress, ToAddress, BCCAddress, CreatedDate, Subject, HasAttachment, Incoming, TextBody, CreatedBy.Name  
            from EmailMessage where ParentId =: currentCase.Id 
            order by MessageDate DESC ];
    return sortedEmails;
  }

public List<Task> getTask() {
    List<Task> Task= new List<Task>();
    Task = [SELECT Id, Priority, Subject, Status, Description, CreatedDate, ActivityDate, CreatedBy.Name,Who.Name
            from Task order by CreatedDate DESC]; 
    return Task;  
  }
}

Here is the Visualforce Page code

<apex:page standardController="Case" showHeader="false" sidebar="false" title="Case Number: {!Case.CaseNumber}" extensions="CaseEmailExtension">
<apex:form >
<apex:pageBlock title="Case Number: {!Case.CaseNumber}">

<apex:pageBlockButtons location="top" >
            <apex:CommandButton value="Print" onclick="javascript:window.print(); return false"/>
            <apex:CommandButton value="Close" onclick="window.close(); return false;"/>
    </apex:pageBlockButtons>

<apex:repeat value="{!sortCommonContainer}" var="cc">

    <apex:pageblock >
    <apex:facet name="header">
        <apex:outputText value="{0,date,dd'.'MM'.'yyyy HH:mm:ss z}" style="font-weight:bold;font-style:italic;font-size:12px;float:left ">
        <apex:param value="{!cc.CreatedDate}" />
        </apex:outputText>
        </apex:facet>
        <td width="100%" align="left">
            <table cellpadding="2px">
                <tr>
                                                
                </tr>
            </table>
        </td>
                
          
        </apex:pageblock>
</apex:repeat>
</apex:form>
</apex:page>
Dear All,

I am creating a visualforce page which would basically capture case related updates (excluding field updates) including Tasks created, Emails Sent, Email recieved , Comments created, custom related lists in chronological fashion on Visualforce page. Any pointers would be appreciated. Thanks.
So I created a custom button in sandbox and kept the content source to be 'URL' and passed '/apex/New_Billing_Information?acctId={!Account.Id}'  but when I do the same thing in Production, It would not call my visual force page... Plz help 
Hello All,

I have written below mentioned code and I am getting "Error: Invalid field Testing__r for SObject Case".

Please note, 'Testing' is a custom object and is related list of Case object

<apex:pageBlockSection id="Testing" columns="1" title="Testing" collapsible="true">
      <apex:pageBlockTable value="{!Case.Testing__r}" var="item">
      <apex:column value="{!item.Name__c}"/>
      
      </apex:pageBlockTable>
      
      </apex:pageBlockSection>
Dear All,

I am creating a visualforce page which opens when we click on a 'Custom' button (/apex/CaseDetail?CaseId={!Case.Id}) placed on Case detail page. I am not able to pass the Account Name of the record into this custom page. 

Below mentioned is the code - I am sure there is some issue with the code..

<apex:page showHeader="false" sidebar="false" standardController="Case">
  <apex:form >
    <apex:pageBlock title="Case Details" mode="maindetail">
    
    <apex:pageBlockButtons location="top">
            <apex:CommandButton value="Print" onclick="javascript:window.print(); return false"/>
            <apex:CommandButton value="Close" onclick="window.close(); return false;"/>
    </apex:pageBlockButtons>
    
    <apex:pageBlockSection id="CaseSumary" columns="3" title="Case Summary" collapsible="true">
          
          <apex:pageBlockSectionItem >
          <apex:outputPanel >
                   <apex:outputLabel value="Account Name:" for="account"/>
                   <apex:outputField id="type" value="{!Case.AccountId}"/>
          </apex:outputPanel> 
          </apex:pageBlockSectionItem>
                                          
     </apex:pageBlockSection>
      
    </apex:pageBlock>
  </apex:form>
</apex:page>


And here is the screenshot of visual force page. You can see that I am not able to get value of the account record.

User-added image

Thanks,
Manpreet Singh