You need to sign in to do that
Don't have an account?
anvesh@force.com
Please help for correct this trigger?
In contacts i have a field TaskTestDate. on this field i should need to display recently opened task date belongs to appropriate record type.
so correct my trigger.
trigger updateTrig on Contact (before insert,before update) {
Task T =new Task();
for(contact c:Trigger.new)
if(t.RecordtypeId=='01240000000UWKG')
c.TaskTestDate__c=t.t.system.now();
}
the T.system.date.now is not correct but how should i make this to populate a date of recently opened task date.
so correct my trigger.
trigger updateTrig on Contact (before insert,before update) {
Task T =new Task();
for(contact c:Trigger.new)
if(t.RecordtypeId=='01240000000UWKG')
c.TaskTestDate__c=t.t.system.now();
}
the T.system.date.now is not correct but how should i make this to populate a date of recently opened task date.
First, record id should not be the hard-coded.
If you want to add a specific date in this field then you can create a date type variable and do the calculation there.
Hi ,
There is a big error in your code I think so,
if(t.RecordtypeId=='01240000000UWKG')
In this line you are comparing t.Recordtype which is wrong I think you C.RecordTypeId should be there
c.TaskTestDate__c=t.t.system.now();
// In this you have written t.t.system.now() which is wrong System.Now() is the correct it gives you DATETIME
I you want to take date then write System.Today();
Why are you creating Task T if it is not in use. And We never do hard coding it makes our code failure in other org. It is a bad practices
Thanks
Ashlekh
If this post helps you than please mark it is a solution and don't forget to give me kudo's
hanks for your reply intially my requirement is
Thanks for your effort but misunderstanding let me clarify you
I would like to create a new Contact field on contact. this field will pull the date of the most recent activity record that fits the following criteria.
TaskTestDate : Most recent task record date of specified record type (i have 3 record types here so assume first record type id as ='00XXXXXXXXXX' ).
EventTestDate : Most recent event record date of specified record type (i have 3 record type ).
sorry for any confusion. and really thanks for your effort.
Actually it is my imagination , when we open any task, on task field it displayes with current datetime (A i mentioned in previously question) , so when i assign this field to contact field it displayes the task opened datetime.
so i have created a field on task and displayed current date , then this field i am trying to assign to contacts field.