You need to sign in to do that
Don't have an account?
Shephali Swarnkar
Solution for copying Description(Long text Area datatype) field contents to Custom field
Hi All,
I had gone through some problems working withDescription field so now I got a solution to work with "Long Text Area DataType", if you want to count() the records or other filtering things with Description.
I made a custom field "Notes__c"(Text Area) in contact object and using Trigger i copied the contents of Description field to Notes__c.
here is the code:
trigger CopydescToNotes on Contact (before insert,before update) {
for(Contact c : Trigger.new)
if(c.Description!=null)
c.Notes__c=c.Description;
}
Thanks
Shephali
I had gone through some problems working withDescription field so now I got a solution to work with "Long Text Area DataType", if you want to count() the records or other filtering things with Description.
I made a custom field "Notes__c"(Text Area) in contact object and using Trigger i copied the contents of Description field to Notes__c.
here is the code:
trigger CopydescToNotes on Contact (before insert,before update) {
for(Contact c : Trigger.new)
if(c.Description!=null)
c.Notes__c=c.Description;
}
Thanks
Shephali
You should do something like: c.Notes__c=c.Description.left(2000);
Or however long your text field is?
You could also do this in a workflow rule, or process builder so am confused why you would develop a programmatic approach?
All Answers
You should do something like: c.Notes__c=c.Description.left(2000);
Or however long your text field is?
You could also do this in a workflow rule, or process builder so am confused why you would develop a programmatic approach?
Yes David absolutly correct that it will throw error when one tries to copy more than 255(text area limit) words.
Yes i tried it with field update in this way : LEFT (Description, FIND(' ', Description)). but it dint work so i tried to resolve my problem using trigger and now i corrected it as per your suggestion.
trigger CopydescToNotes on Contact (before insert,before update) {
for(Contact c : Trigger.new)
if(c.Description!=null)
c.Notes__c=c.Description.left(255);(or <=255)
}
Thanks
Shephali
Shephali
Excellent, please feel free to mark my response as the accepted solution if you found it helped :)
Many thanks