You need to sign in to do that
Don't have an account?
Sean Clark
Apex Trigger to create a task on MVP object (Only Create on a weekday)
I have created a Apex Trigger to create a task on the MVP object when the Last Contacted On date is 30 days old.
Is there anyway i can make it so that the task will only be created on a weekday? (Monday - Friday)
trigger OldMVPTrigger on MVP__c (after insert) {
List<Task> taskListToInsert = new List<task>();
for(MVP__c mvp:Trigger.new)
{
if(mvp.Last_Contacted_On__c == Date.Today().addDays(-30))
{
task t = new Task();
t.Subject = 'Call [MVP__c].MVP__c.FirstName Today';
t.OwnerId = '[MVP__c].MVP_Owner__c';
t.WhatId = mvp.Id;
taskListToInsert.add(t);
}
}
if(taskListToInsert.size() > 0)
{
insert taskListToInsert;
}
}
Is there anyway i can make it so that the task will only be created on a weekday? (Monday - Friday)
trigger OldMVPTrigger on MVP__c (after insert) {
List<Task> taskListToInsert = new List<task>();
for(MVP__c mvp:Trigger.new)
{
if(mvp.Last_Contacted_On__c == Date.Today().addDays(-30))
{
task t = new Task();
t.Subject = 'Call [MVP__c].MVP__c.FirstName Today';
t.OwnerId = '[MVP__c].MVP_Owner__c';
t.WhatId = mvp.Id;
taskListToInsert.add(t);
}
}
if(taskListToInsert.size() > 0)
{
insert taskListToInsert;
}
}
Please try following code.
All Answers
Please try following code.
Thank you for this!