//1st Scenario
trigger updatingStatus on project__c (before insert, before update) {
for(project__c v : [Link]){
// checking for a condition
if(v.StartDate__c < [Link]() && v.status__c !='In Progress'){
v.status__c ='In Progress';
}
if (v.EndDate__c <[Link]() && v.status__c !='Completed'){
v.status__c ='Completed';
}
}
}
//2nd Scenario
trigger taskCreation on project__c (after insert , after update) {
//Listing Task to insert
List<Task__c> taskToInsert = new List<Task__c>();
// collecting all project ids for task creation
Set<ID> projectIds = new set<ID>();
// Map to track which record is updated
Map<Id,project__c> projectsToUpdate = new Map<Id,project__c> ();
for (project__c v : [Link] ) {
if ([Link] || v.Milestone__c !=
[Link]([Link]).Milestone__c){
[Link]([Link]);
[Link]([Link] ,v);
}
}
//Query the Milestone for a specified project
Map<Id,List<string>> projectMilestones = new Map<Id,List<string>>();
for(project__c v : [select ID , Milestone__c from project__c where Id
IN :projectIds ]){
if(){
[Link]([Link], v.Milestone__c.split(','));
}else{
[Link]([Link], new List<string>());
}
}
//creating Task for Each project
for(Id projectid : projectIds){
List<string> milestones = [Link](projectId);
for(string milestone : milestones ){
Task__c task = new Task__c();
task.project__c = projectId;
task.Milestone__c = [Link]();
task.status__c = 'Not Started';
[Link](task);
}
}
if (![Link]()){
insert tasksTOInsert;
}