You need to sign in to do that
Don't have an account?
sudha76
Trigger to copy values from Description field to the custom field.
I am looking for an example to create a Trigger that will copy the first n character (255 characters) from the TASK standard field called - Description to the custom field under TASKS called - "Extract Task Heading".
Any examples on how to copy values within same object and different fields would also help?
thanks.
Instead you can achieve this by using workflow rules -> field update facility.
Below link will explain in short.
https://www.youtube.com/watch?v=eG78LF2qa1I
Thanks,
All Answers
Instead you can achieve this by using workflow rules -> field update facility.
Below link will explain in short.
https://www.youtube.com/watch?v=eG78LF2qa1I
Thanks,
Sudha,
Try below :
trigger copyDescFieldonTask on Task (before insert, before update) {
if((Trigger.isInsert || Trigger.isUpdate) && Trigger.isBefore){
for(Task tsk: Trigger.new){
if(tsk.Description != null)
if(tsk.Description.length() > 255)
tsk.Extract_Task_Heading__c= tsk.Description.substring(0,255);
else
tsk.Extract_Task_Heading__c= tsk.Description;
}
}
}
Thanks everyone for their thoughts on this subject.
I resolved this issue by using a WF Rule. Some of the things I noticed was, Sales force does not allow to access some of the standard TASK fields including Description through custom formula field created under Activity Custom Fields.
Whereas, if I create a WF Rule on TASKS and update the Activity Custom Field, using a field update through Formula, I can easily access "Description" Field.
Not sure, why but that is what I saw so I am sharing with everyone.
So, I did a WF Rule on TASKS which is doing the field update on the custom field called "Comments_Heading__c" that is copying the first statement of the content entered in the "Description" field, through this formula.
LEFT (Description, FIND('. ', Description))
thanks.
* Long text area, encrypted, and Description fields are not available for use in formulas.
http://login.salesforce.com/help/doc/en/tips_on_building_formulas.htm#formula_display_1300