1. Entitlement have a multiple cases
2. Case have multiple Task
3. Rollup Task to Entitlement
Trigger:
trigger trgTaskDueDateUpd on Task (after insert, after update, after delete) {
if (!System.label.SYS_RunTaskTrigger.equalsIgnoreCase(System.Label.SYS_TRIGGER_NO)) {
ClsTriggerTaskHandler clsTaskhdr = new ClsTriggerTaskHandler();
if ((Trigger.isAfter && Trigger.isInsert)|| (Trigger.isAfter && Trigger.isUpdate))
{
clsTaskhdr.setDueDateFunction(Trigger.new,Trigger.old, Trigger.oldMap,True,False);
}
if (Trigger.isAfter && Trigger.isDelete)
{
clsTaskhdr.setDueDateFunction(Trigger.new,Trigger.old, Trigger.oldMap,False,True);
}
/* if (Trigger.isAfter && Trigger.isUpdate)
{
clsTaskhdr.ClsTriggerRolluHandler(Trigger.new,Trigger.old, Trigger.oldMap,True,False);
}*/
}
}
Trigger Handler
/*
Grandparent : Entitlement
Parent : Case
Child : Task
*/
public void setRollupsummaryent(List<task> lstask)
{
if(Trigger.isUpdate)
{
Set<Id> caseId = new Set<Id>();
for(Task ts1 : lstask)
{
caseId.add(ts1.whatId);
}
Set<Id> entId = new Set<Id>();
for(Case cs : [select Entitlementid, (Select Id,Duration__c from Tasks) from case where id in : caseId])
{
entId.add(cs.EntitlementId);
}
Map<Id,Decimal> entWithDuration = new Map<Id,Decimal>();
for(Case cs : [select Entitlementid, (Select Id,Duration__c from Tasks) from case where Entitlementid in : entId ])
{
Decimal duration = 0;
for(Task tk: cs.tasks){
duration += tk.Duration__c;
System.debug('&&&&&&&&&&&&' + duration);
}
2. Case have multiple Task
3. Rollup Task to Entitlement
Trigger:
trigger trgTaskDueDateUpd on Task (after insert, after update, after delete) {
if (!System.label.SYS_RunTaskTrigger.equalsIgnoreCase(System.Label.SYS_TRIGGER_NO)) {
ClsTriggerTaskHandler clsTaskhdr = new ClsTriggerTaskHandler();
if ((Trigger.isAfter && Trigger.isInsert)|| (Trigger.isAfter && Trigger.isUpdate))
{
clsTaskhdr.setDueDateFunction(Trigger.new,Trigger.old, Trigger.oldMap,True,False);
}
if (Trigger.isAfter && Trigger.isDelete)
{
clsTaskhdr.setDueDateFunction(Trigger.new,Trigger.old, Trigger.oldMap,False,True);
}
/* if (Trigger.isAfter && Trigger.isUpdate)
{
clsTaskhdr.ClsTriggerRolluHandler(Trigger.new,Trigger.old, Trigger.oldMap,True,False);
}*/
}
}
Trigger Handler
/*
Grandparent : Entitlement
Parent : Case
Child : Task
*/
public void setRollupsummaryent(List<task> lstask)
{
if(Trigger.isUpdate)
{
Set<Id> caseId = new Set<Id>();
for(Task ts1 : lstask)
{
caseId.add(ts1.whatId);
}
Set<Id> entId = new Set<Id>();
for(Case cs : [select Entitlementid, (Select Id,Duration__c from Tasks) from case where id in : caseId])
{
entId.add(cs.EntitlementId);
}
Map<Id,Decimal> entWithDuration = new Map<Id,Decimal>();
for(Case cs : [select Entitlementid, (Select Id,Duration__c from Tasks) from case where Entitlementid in : entId ])
{
Decimal duration = 0;
for(Task tk: cs.tasks){
duration += tk.Duration__c;
System.debug('&&&&&&&&&&&&' + duration);
}
No comments:
Post a Comment