You need to sign in to do that
Don't have an account?
Method does not exist or incorrect signature: NOW()
Hi community, I am new in Apex language, I am trying to create a simple trigger to update a contact field but when I try to put a condition with the method NOW() or TODAY() it returns this error : Method does not exist or incorrect signature: NOW(). Do you know why? Here is my code :
trigger UpdtConAct on Event (after insert, after update) {
// create a set for related contact ids
Set<ID> contactids = new Set<ID>();
// iterate through the events
for ( Event status : trigger.new){
// add the event only if the surgery appened less than 30 days ago
if (status.Subject == 'Surgery'){
if ( (Status.ActivityDate.daysbetween(NOW())) < 30 )
{contactids.add(status.WhoId);}
}
}
// use SOQL to query for the relevant contact
List <Contact> contactlist = [SELECT id ,Surgeon_Status__c from Contact where id in : contactids];
// iterate through the contacts
for (Contact con : contactlist){
con.Surgeon_Status__c='Active';}
update contactlist;
}
Thanks for your answer.
Pierre
if ( (Status.ActivityDate.daysbetween(Date.Today())) < 30 )
Pierre