function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DougR73DougR73 

Copy field data and append to another field

I have created a custom object which is going to be used for an internal support team.

 

Users will be entering in comments into the 'Comments' field that need to be date/time stamped and retained (nobody except sysadmin can edit once saved).

 

Only solution I can think of (but do not know how to accomplish):

There is a long text area field that comments will be entered.  When the record is saved, I would like to cut the text in this field and append it into another long text area field with a date/time stamp at the beginning of the line.  I can then make this field read-only to everybody but the sysadmin profile.

 

Help would be greatly appreciated!

 

 

snugglessnuggles
Sounds like you could use the standard case object and case comments functionality.  You could do this the way you described, with a trigger on the custom object.  The trigger could take the new comments field, append it to the beginning of the other text area, time stamped, then clear the original comments field.  Would be a fairly straight forward before insert/update trigger.  You could also have a secondary "comments" custom object that pointed back to the master object, this is more how the standard case comments work.  You could then just utilize the built in audit fields, createdDate, and lastModifiedDate.
srichardsonsrichardson

I saw this done with a workflow rule and field update at Dreamforce '11. The solution was created by Steve Molis from Epsilon.

 

Requirement
Create an ‘append only’ text field, similar to Case Comments or Notes and Attachments with Last Updated By User and a Timestamp.
Solution
Workflow Rule and Field Update
Fields Referenced
Custom: Long Text Fields
System Fields:
LastModifiedBy.Username and LastModifiedDate
Functions Used
ISCHANGED, PRIORVALUE, TEXT
Rule criteria = Every time a record is created or edited
Evaluation criteria =ISCHANGED(Text_Area__c)
Field Update details:
PRIORVALUE(Formula_LongText__c) + BR() +
LastModifiedBy.Username + BR() +
TEXT(LastModifiedDate - $User.GMT__c) + BR() +
Text_Area__c


jacoclockedjacoclocked

Nice work. Need to make it to dreamforce this year.