+ Start a Discussion
gringoesegringoese 

Need Text Area (Long) field for an Activity Task

Is there any possible way I can create a Text Area (Long) field type for an Activity Task? I don't see any option for this when creating a custom field. I need it badly.

 

There seems to be a lot of random limitations when working with Activity Tasks and Events which is very frustrating. 

jhurstjhurst

gringoese,

 

Additional Long Text Area fields are not available on Tasks and Events.  The standard "Description" field is a LTA with a 32,000 character limit, so that may suit your needs.

 

There may be ways to get the behavior you want, but it would require additional coding and implementation.  One idea that may work would be to create a custom object which contains as many LTA fields as you need along with an 18 character text field to hold a salesforce.com id.

 

The idea would be that you would override the Task create page to display a VF page that has all of the task fields and then text boxes he number of LTA fields you created on the custom object.  When you save the Task, you would have the Apex controller also create a custom object record.  The text areas would populate into the custom object LTA fields and the Task ID would populate into the 18 character text field.  You would then have to create a Visualforce page to verride the Task View page so that you could display the Task record and the custom object record.

 

Obviously this would be a bit of extra work, so it would depend on your specific needs.

 

Hope this helps

Jay

BLachanceBLachance

jhurst -

 

I am new to Visualforce, and I am looking to exactly what you suggested in this post - could you explain how to make the apex controller create the custom object and populate the 18 character text field. an example code would be great as well.

 

thank you in advance for any help.

 

Bob

 

jhurstjhurst

Bob,

 

As mentioned, this would be a quite significant amount of coding (especially to test it completely).  I would not really be able to give you a full working solution.

 

An example of the page to display the records would be:

 

<apex:page standardController="Task" extensions="taskLTAExtension">
    <apex:detail /> 
    <apex:pageBlock title="Task LTA Fields">
        <apex:pageBlockTable value="{!TLTA}" var="tlta">
            <apex:column value="{!tlta.LTA_1__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 And the extension would look like:

public with sharing class taskLTAExtension {

    private final Task tsk;
    private final Task_LTA__c tLTA;
    
    public taskLTAExtension(ApexPages.StandardController controller) {
        this.tsk = (Task)controller.getRecord();
        this.tLTA = [select id, Parent_Task__c, LTA_1__c from Task_LTA__c where Parent_Task__c = :tsk.id];
    }

    public Task_LTA__c getTLTA() {
        return tLTA;
    }

}

 This would show the Task Detail and display the LTA_1__c field on all associated Task_LTA__c records (the Task_LTA__c would be a custom object which contains a field calles Parent_Task__c which would be the 18 character task ID, and a LTA_1__c field which would be the long text area).

 

You would have to build the edit/new page which would replicate the exisitng task create, and then add LTA fields.  On the save action, you would save the Task information, and then add a new Task_LTA__c record with the Parent_Task__c field set to the ID of teh task that was created and the LTA_1__c field set to the value you entered on the Task edit page.

 

The VF Docs should be able to help you a bit further, too - http://www.salesforce.com/us/developer/docs/pages/index.htm

 

Hope this gets you started

Jay

BLachanceBLachance

Your examples were great I was able to build what I needed from them.  I am stuck though on how to get the Task ID to populate in the custom object Parent Task field. I thought it would be a simple = statement - but that didn't work - most likely because it is the wrong way. Could you help out again? How do I get the task ID and put it in the Parent field?

 

Again I appreciate your help, I have been scouring the web for idea's.

 

Bob

 

 

jhurstjhurst

There are quite a few examples on the discussion boards :)

 

I found this one - http://boards.developerforce.com/t5/Visualforce-Development/BUG-New-Task-from-Opportunity-with-Edit-link-Override/m-p/131165/highlight/true#M13577

 

From there, I put together a VF page and an Apex class:

 

<apex:page standardController="Task" tabstyle="Task" extensions="taskLTAEditExtension">
    <apex:form >
        <apex:sectionHeader title="Task" subtitle="{!t.Subject}"></apex:sectionHeader>
        <apex:pageBlock title="Task Edit" id="thePageBlock" mode="edit">
            <apex:pageMessages />
            <apex:pageBlockButtons location="both">
                <apex:commandButton value="Save" action="{!saveAction}" />
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageblockSection title="Task Information">
                <apex:inputfield value="{!t.OwnerID}" />
                <apex:inputfield required="false" id="task__status" value="{!t.Status}" />
                <apex:inputfield required="false" id="task__subject" value="{!t.Subject}" />
                <apex:inputfield id="task__type" value="{!t.type}" />
                <apex:inputfield required="false" id="task__activitydate" value="{!t.ActivityDate}" />
                <apex:inputfield id="task__name" value="{!t.WhoId}" />
                <apex:inputfield required="false" id="task__priority" value="{!t.Priority}" />
                <apex:inputfield id="task__relatedto" value="{!t.WhatId}" />
                <apex:inputfield id="task__lta" value="{!tLTA.LTA_1__c}" />
            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

public class taskLTAEditExtension {

    public Task t {get;set;}
    public Task_LTA__C tLTA {get;set;}

    public taskLTAEditExtension(ApexPages.StandardController c) {
        t = (Task) c.getRecord();
        tLTA = new Task_LTA__c();
        if(t.Id == null){
            t.whoId = null;
        }
        else{
            t = [SELECT Subject, OwnerID, Status, Type, ActivityDate, WhoId, WhatId, Priority 
                 FROM Task WHERE Id = :t.Id];
            tLTA = [SELECT Id, Parent_Task__c, LTA_1__c from Task_LTA__c where Parent_Task__c = :t.Id];
        }
    }
    
    public void saveAction() {
        if(t.Id == null){
            insert t;
        }
        else{
            update t;
        }
        if(tLTA.Id == null){
            tLTA.Parent_Task__c = t.Id;
            insert tLTA;
        }
        else{
            update tLTA;
        }
    }
    
}

 This worked in the few simple tests I did.  Note that the saveAction() method sets the value:

 

if(tLTA.Id == null){
    tLTA.Parent_Task__c = t.Id;
    insert tLTA;
}

 Hope this helps.

Jay

Angela SchloederAngela Schloeder
Using this has worked to have a long text area field on Task vf pages, but now I'm having issues reporting on that field.
Glynn Smith 9Glynn Smith 9
Hi, 

How did you test the Apex class? 

Thanks 

Glynn 
Angela SchloederAngela Schloeder
Thanks for the reply Glynn. I have since figured out what I was doing wrong with the reporting.