You need to sign in to do that
Don't have an account?
how to do this..
"There is a text box on case page layout. User can enter text into it. Whenever user type <today> in the text, while saving the case, today should be replaced by today’s date"
I tried this trigger but it works only when new case is created..but donot when case is edited.
trigger dateconvert on Case (after insert)
{
for(Case case1:System.Trigger.new)
{
Case ca=[select Enter_text__c from Case where CaseNumber =:case1.CaseNumber ];
date myDate = date.today();
String abc = myDate .format();
String NewEntry=ca.Enter_text__c.replaceAll('today',abc);
ca.Enter_text__c=NewEntry;
update ca;
}
}
Hi,
Here you forgot to include update Event for trigger, then how it will work for update operation.
Write Update trigger event for the trigger. then it will work for update operation also.
Hi Haridinesh,
The above only converts the whole line to todays date.....not like iif line is 'today is Monday"---->>>>"10/9/2012 is Monday"
Hi,
Yes, by observing the code I told that.
But as per your description in first post
"Whenever user type <today> in the text, while saving the case, today should be replaced by today’s date"
There is no such condition like that is what am saying.
OK, if you don't what that condition leave it.
Does your question is answered by my post or not, or you looking for something other?
Haridinesh..
my code is working for new case .Can you help me so that it also work of existing record.
here is exact screnerio...
"There is a text box on case page layout. User can enter text into it. Whenever user type <today> in the text, while saving the case, today should be replaced by today’s date."
Hi,
The above code in my post will do that thing.
it will work for Existing record.
But one thing we need to add is check like whether enterted text is <today> or not.
Add below code to the above posted code.
for(case as1 : trigger.new)
{
if(as1.Enter_text__c == '%<today>%')
as1.Enter_text__c = string.valueof(date.today());
}
so Find complete code
}