-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
2Questions
-
6Replies
Update field before delete trigger
Hello everybody,
I am trying to build a simple Apex trigger that updates a Lead field upon its deletion, or more correctly just before it gets deleted. The scope for this, is that this field update fires another process, so I am actually not even sure if this will work the way I am anticipating, but since I am learning more about Apex triggers, it could still be an valuable exercise.
Here is a draft of my trigger, which unfortunately is not correct
trigger my_delete_trigger on Lead (before Delete) {
for (Lead trigger.old){update custom_id__c = a0g5800000A4O0Z;}
}
Any help on this would be greatly appreciated.
- Efstathios Ntatsios 6
- January 23, 2018
- Like
- 0
Trigger issues
trigger CountTask on Task (after insert, after update) {
public List<Task> ltask1 = new List<Task>();
public id oppid;
public integer inp=0;
public integer inr=0;
for(Task t:Trigger.New){
oppid = t.WhatId;
system.debug('oppid'+oppid);
}
ltask1 = [select id,Status from task where whatid=:oppid];
system.debug('oppsize'+ltask1.size());
for(task t:ltask1){
if(t.Status!='Abgeschlossen'){
inp = inp+1;
} else{
inr = inr +1;
}
}
List<Opportunity> opp = new List<opportunity>();
List<opportunity> op = [select id from Opportunity where id = :oppid];
system.debug('oppsize'+op.size());
for(opportunity o: op){
o.Open_Tasks__c = inp;
o.Closed_Tasks__c = inr;
opp.add(o);
}
if(opp.size()>0){
update opp;
}
system.debug('No of Tasks'+inp+inr);
}
when trying to create a task on an opportunity I get the the following error:
CountTask: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id 0065800000MKq82AAD; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] Trigger.CountTask: line 32, column 1
Since I am a bit new with Apex triggers, could someone explain, what do I need to do to fix this?
Thank you very much in advance
Debug Log:
30.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
16:28:44.2 (2103082)|ENTERING_MANAGED_PKG|APXTConga4
16:28:44.2 (11606583)|SOQL_EXECUTE_BEGIN|[46]|Aggregations:0|SELECT id, APXTConga4__WhatId__c FROM APXTConga4__Conga_Email_Staging__c
16:28:44.2 (17655073)|SOQL_EXECUTE_END|[46]|Rows:0
16:28:44.18 (18693349)|CUMULATIVE_LIMIT_USAGE
16:28:44.18 (18693349)|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.18 (18693349)|LIMIT_USAGE_FOR_NS|APXTConga4|
Number of SOQL queries: 1 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.18 (18693349)|CUMULATIVE_LIMIT_USAGE_END
16:28:44.166 (166843648)|CODE_UNIT_STARTED|[EXTERNAL]|01q3E000000CzBl|Counttasks on Task trigger event AfterInsert for [00T3E000006N4P7]
16:28:44.166 (166926635)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
16:28:44.166 (167097773)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:10
16:28:44.166 (167215648)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:28
16:28:44.166 (167237693)|VARIABLE_SCOPE_BEGIN|[1]|this|Counttasks|true|false
16:28:44.166 (167316006)|VARIABLE_ASSIGNMENT|[1]|this|{}|0xba5e15e
16:28:44.166 (167401981)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:28
16:28:44.166 (167726154)|VARIABLE_SCOPE_BEGIN|[1]|this|Counttasks|true|false
16:28:44.166 (167769513)|VARIABLE_ASSIGNMENT|[1]|this|{}|0xba5e15e
16:28:44.166 (167782415)|STATEMENT_EXECUTE|[1]
16:28:44.166 (167784464)|STATEMENT_EXECUTE|[3]
16:28:44.166 (167814696)|HEAP_ALLOCATE|[3]|Bytes:4
16:28:44.166 (167882366)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
16:28:44.166 (167897985)|VARIABLE_ASSIGNMENT|[3]|this.ltask1|[]|0xba5e15e
16:28:44.166 (167904053)|STATEMENT_EXECUTE|[4]
16:28:44.166 (167916662)|VARIABLE_ASSIGNMENT|[4]|this.oppid|null|0xba5e15e
16:28:44.166 (167922885)|STATEMENT_EXECUTE|[5]
16:28:44.166 (167930867)|HEAP_ALLOCATE|[5]|Bytes:4
16:28:44.166 (167940385)|VARIABLE_ASSIGNMENT|[5]|this.inp|0|0xba5e15e
16:28:44.166 (167945619)|STATEMENT_EXECUTE|[6]
16:28:44.166 (167951062)|HEAP_ALLOCATE|[6]|Bytes:4
16:28:44.166 (167959200)|VARIABLE_ASSIGNMENT|[6]|this.inr|0|0xba5e15e
16:28:44.166 (168076642)|HEAP_ALLOCATE|[7]|Bytes:5
16:28:44.166 (168163019)|VARIABLE_SCOPE_BEGIN|[7]|t|Task|true|false
16:28:44.166 (183115571)|VARIABLE_ASSIGNMENT|[7]|t|{"LastModifiedDate":"2017-10-23T14:28:44.000Z","AccountId":"0015800000rcsReAAI","WhatId":"0065800000MKq82AAD","WhatCount":1,"IsHighPriority":false,"IsClosed":false,"WhoCount":0,"CreatedById":"00558000001scKvAAI","OwnerId":"00558000001scKvAAI","RecordTypeId":"01258000000cf60AAA","IsReminderSet":false,"CallAttptDateVa__c":"2017-10-23T14:28:44.000Z","Agent_ID__c":"00558000001scKv","Status":"Offen","QualifiedVa__c":false,"IsDeleted":false,"ActivityDate":"2017-10-27T00:00:00.000Z","Priority":"Normal","Qualified__c":false,"CurrencyIsoCode":"EUR","IsRecurrence":false,"Subject":"Test task","SystemModstamp":"2017-10-23T14:28:44.000Z","IsArchived":false,"Overdue_Task__c":"Not yet due","TaskSubtype":"Task","CreatedDate":"2017-10-23T14:28:44.000Z","Id":"00T3E000006N4P7UAK","etreminder__Reminder (3 more) ...":false,"LastModifiedById":"00558000001scKvAAI"}|0x4b02ac77
16:28:44.166 (183156343)|STATEMENT_EXECUTE|[7]
16:28:44.166 (183158555)|STATEMENT_EXECUTE|[8]
16:28:44.166 (183418924)|VARIABLE_ASSIGNMENT|[8]|this.oppid|"0065800000MKq82AAD"|0xba5e15e
16:28:44.166 (183428932)|STATEMENT_EXECUTE|[9]
16:28:44.166 (183436148)|HEAP_ALLOCATE|[9]|Bytes:5
16:28:44.166 (183536527)|HEAP_ALLOCATE|[9]|Bytes:18
16:28:44.166 (183599211)|HEAP_ALLOCATE|[9]|Bytes:23
16:28:44.166 (183637592)|USER_DEBUG|[9]|DEBUG|oppid0065800000MKq82AAD
16:28:44.166 (183674707)|HEAP_ALLOCATE|[7]|Bytes:5
16:28:44.166 (183707930)|VARIABLE_ASSIGNMENT|[7]|t|null|
16:28:44.166 (183720883)|STATEMENT_EXECUTE|[12]
16:28:44.166 (183726941)|HEAP_ALLOCATE|[12]|Bytes:51
16:28:44.166 (183759355)|HEAP_ALLOCATE|[12]|Bytes:4
16:28:44.166 (184248439)|SOQL_EXECUTE_BEGIN|[12]|Aggregations:0|SELECT id, Status FROM task WHERE whatid = :tmpVar1
16:28:44.166 (210054678)|SOQL_EXECUTE_END|[12]|Rows:1
16:28:44.166 (210102431)|HEAP_ALLOCATE|[12]|Bytes:8
16:28:44.166 (210127862)|HEAP_ALLOCATE|[12]|Bytes:44
16:28:44.166 (210190225)|HEAP_ALLOCATE|[12]|Bytes:8
16:28:44.166 (210271650)|VARIABLE_ASSIGNMENT|[12]|this.ltask1|[{"Id":"00T3E000006N4P7UAK","Status":"Offen"}]|0xba5e15e
16:28:44.166 (210283838)|STATEMENT_EXECUTE|[13]
16:28:44.166 (210291150)|HEAP_ALLOCATE|[13]|Bytes:7
16:28:44.166 (210392442)|HEAP_ALLOCATE|[13]|Bytes:1
16:28:44.166 (210413354)|HEAP_ALLOCATE|[13]|Bytes:8
16:28:44.166 (210430785)|USER_DEBUG|[13]|DEBUG|oppsize1
16:28:44.166 (210511107)|HEAP_ALLOCATE|[16]|Bytes:5
16:28:44.166 (210548229)|HEAP_ALLOCATE|[16]|Bytes:12
16:28:44.166 (210568605)|VARIABLE_SCOPE_BEGIN|[16]|t|Task|true|false
16:28:44.166 (210591779)|VARIABLE_ASSIGNMENT|[16]|t|{"Id":"00T3E000006N4P7UAK","Status":"Offen"}|0x1f929a41
16:28:44.166 (210601216)|STATEMENT_EXECUTE|[16]
16:28:44.166 (210637116)|HEAP_ALLOCATE|[17]|Bytes:9
16:28:44.166 (210670079)|STATEMENT_EXECUTE|[17]
16:28:44.166 (210671997)|STATEMENT_EXECUTE|[18]
16:28:44.166 (210686339)|HEAP_ALLOCATE|[18]|Bytes:4
16:28:44.166 (210699455)|VARIABLE_ASSIGNMENT|[18]|this.inp|1|0xba5e15e
16:28:44.166 (210717258)|HEAP_ALLOCATE|[16]|Bytes:5
16:28:44.166 (210733116)|VARIABLE_ASSIGNMENT|[16]|t|null|
16:28:44.166 (210745375)|STATEMENT_EXECUTE|[23]
16:28:44.166 (210778777)|HEAP_ALLOCATE|[23]|Bytes:4
16:28:44.166 (210859430)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
16:28:44.166 (210872795)|VARIABLE_ASSIGNMENT|[23]|this.opp|[]|0xba5e15e
16:28:44.166 (210879797)|STATEMENT_EXECUTE|[24]
16:28:44.166 (210883638)|HEAP_ALLOCATE|[24]|Bytes:46
16:28:44.166 (210901808)|HEAP_ALLOCATE|[24]|Bytes:4
16:28:44.166 (211225629)|SOQL_EXECUTE_BEGIN|[24]|Aggregations:0|SELECT id FROM Opportunity WHERE id = :tmpVar1
16:28:44.166 (228382474)|SOQL_EXECUTE_END|[24]|Rows:1
16:28:44.166 (228423557)|HEAP_ALLOCATE|[24]|Bytes:8
16:28:44.166 (228445757)|HEAP_ALLOCATE|[24]|Bytes:29
16:28:44.166 (228509663)|HEAP_ALLOCATE|[24]|Bytes:8
16:28:44.166 (228590026)|VARIABLE_ASSIGNMENT|[24]|this.op|[{"Id":"0065800000MKq82AAD"}]|0xba5e15e
16:28:44.166 (228602917)|STATEMENT_EXECUTE|[25]
16:28:44.166 (228699301)|HEAP_ALLOCATE|[25]|Bytes:1
16:28:44.166 (228720486)|HEAP_ALLOCATE|[25]|Bytes:8
16:28:44.166 (228757069)|USER_DEBUG|[25]|DEBUG|oppsize1
16:28:44.166 (228950342)|HEAP_ALLOCATE|[26]|Bytes:5
16:28:44.166 (228986680)|HEAP_ALLOCATE|[26]|Bytes:8
16:28:44.166 (229004080)|VARIABLE_SCOPE_BEGIN|[26]|o|Opportunity|true|false
16:28:44.166 (229024855)|VARIABLE_ASSIGNMENT|[26]|o|{"Id":"0065800000MKq82AAD"}|0x3cd4bd33
16:28:44.166 (229032667)|STATEMENT_EXECUTE|[26]
16:28:44.166 (229034029)|STATEMENT_EXECUTE|[27]
16:28:44.166 (229080362)|HEAP_ALLOCATE|[27]|Bytes:28
16:28:44.166 (229087921)|HEAP_ALLOCATE|[27]|Bytes:28
16:28:44.166 (229148700)|HEAP_ALLOCATE|[27]|Bytes:-4
16:28:44.166 (229165722)|VARIABLE_ASSIGNMENT|[27]|this.Open_Tasks__c|1|0x3cd4bd33
16:28:44.166 (229171858)|STATEMENT_EXECUTE|[28]
16:28:44.166 (229190966)|HEAP_ALLOCATE|[28]|Bytes:28
16:28:44.166 (229197103)|HEAP_ALLOCATE|[28]|Bytes:28
16:28:44.166 (229229141)|HEAP_ALLOCATE|[28]|Bytes:-4
16:28:44.166 (229240584)|VARIABLE_ASSIGNMENT|[28]|this.Closed_Tasks__c|0|0x3cd4bd33
16:28:44.166 (229246898)|STATEMENT_EXECUTE|[29]
16:28:44.166 (229295763)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
16:28:44.166 (229331151)|HEAP_ALLOCATE|[26]|Bytes:5
16:28:44.166 (229351385)|VARIABLE_ASSIGNMENT|[26]|o|null|
16:28:44.166 (229392780)|STATEMENT_EXECUTE|[31]
16:28:44.166 (229396733)|STATEMENT_EXECUTE|[32]
16:28:44.166 (229472763)|DML_BEGIN|[32]|Op:Update|Type:Opportunity|Rows:1
16:28:44.166 (229520965)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
16:28:44.320 (320138761)|ENTERING_MANAGED_PKG|Five9LSP
16:28:44.320 (325816235)|ENTERING_MANAGED_PKG|Five9LSP
16:28:44.320 (325879741)|ENTERING_MANAGED_PKG|Five9LSP
16:28:44.320 (326061566)|ENTERING_MANAGED_PKG|Five9LSP
16:28:44.332 (332314872)|CUMULATIVE_LIMIT_USAGE
16:28:44.332 (332314872)|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 2 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 1 out of 150
Number of DML rows: 1 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.332 (332314872)|LIMIT_USAGE_FOR_NS|APXTConga4|
Number of SOQL queries: 1 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.332 (332314872)|CUMULATIVE_LIMIT_USAGE_END
16:28:44.166 (337368997)|CODE_UNIT_STARTED|[EXTERNAL]|01q58000000eNwB|OpportunityTrigger on Opportunity trigger event BeforeUpdate for [0065800000MKq82]
16:28:44.166 (337404714)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
16:28:44.166 (337413925)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
16:28:44.166 (337458882)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
16:28:44.166 (337472388)|VARIABLE_SCOPE_BEGIN|[1]|this|OpportunityTrigger|true|false
16:28:44.166 (337540283)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x79af66c3
16:28:44.166 (337586081)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
16:28:44.166 (337598233)|VARIABLE_SCOPE_BEGIN|[1]|this|OpportunityTrigger|true|false
16:28:44.166 (337614878)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x79af66c3
16:28:44.166 (337623491)|STATEMENT_EXECUTE|[1]
16:28:44.166 (337637315)|STATEMENT_EXECUTE|[3]
16:28:44.166 (337646669)|STATEMENT_EXECUTE|[6]
16:28:44.337 (337650964)|CUMULATIVE_LIMIT_USAGE
16:28:44.337 (337650964)|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 2 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 1 out of 150
Number of DML rows: 1 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.337 (337650964)|LIMIT_USAGE_FOR_NS|APXTConga4|
Number of SOQL queries: 1 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.337 (337650964)|CUMULATIVE_LIMIT_USAGE_END
16:28:44.166 (339259338)|CODE_UNIT_FINISHED|OpportunityTrigger on Opportunity trigger event BeforeUpdate for [0065800000MKq82]
16:28:44.166 (389961988)|DML_END|[32]
16:28:44.166 (390113032)|EXCEPTION_THROWN|[32]|System.DmlException: Update failed. First exception on row 0 with id 0065800000MKq82AAD; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []
16:28:44.166 (390843952)|HEAP_ALLOCATE|[32]|Bytes:144
16:28:44.166 (391119104)|FATAL_ERROR|System.DmlException: Update failed. First exception on row 0 with id 0065800000MKq82AAD; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []
Trigger.Counttasks: line 32, column 1
16:28:44.166 (391137831)|FATAL_ERROR|System.DmlException: Update failed. First exception on row 0 with id 0065800000MKq82AAD; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []
Trigger.Counttasks: line 32, column 1
16:28:44.391 (391143142)|CUMULATIVE_LIMIT_USAGE
16:28:44.391 (391143142)|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 2 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 1 out of 150
Number of DML rows: 1 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.391 (391143142)|LIMIT_USAGE_FOR_NS|APXTConga4|
Number of SOQL queries: 1 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.391 (391143142)|CUMULATIVE_LIMIT_USAGE_END
- Efstathios Ntatsios 6
- October 24, 2017
- Like
- 0
Update field before delete trigger
Hello everybody,
I am trying to build a simple Apex trigger that updates a Lead field upon its deletion, or more correctly just before it gets deleted. The scope for this, is that this field update fires another process, so I am actually not even sure if this will work the way I am anticipating, but since I am learning more about Apex triggers, it could still be an valuable exercise.
Here is a draft of my trigger, which unfortunately is not correct
trigger my_delete_trigger on Lead (before Delete) {
for (Lead trigger.old){update custom_id__c = a0g5800000A4O0Z;}
}
Any help on this would be greatly appreciated.
- Efstathios Ntatsios 6
- January 23, 2018
- Like
- 0
Trigger issues
trigger CountTask on Task (after insert, after update) {
public List<Task> ltask1 = new List<Task>();
public id oppid;
public integer inp=0;
public integer inr=0;
for(Task t:Trigger.New){
oppid = t.WhatId;
system.debug('oppid'+oppid);
}
ltask1 = [select id,Status from task where whatid=:oppid];
system.debug('oppsize'+ltask1.size());
for(task t:ltask1){
if(t.Status!='Abgeschlossen'){
inp = inp+1;
} else{
inr = inr +1;
}
}
List<Opportunity> opp = new List<opportunity>();
List<opportunity> op = [select id from Opportunity where id = :oppid];
system.debug('oppsize'+op.size());
for(opportunity o: op){
o.Open_Tasks__c = inp;
o.Closed_Tasks__c = inr;
opp.add(o);
}
if(opp.size()>0){
update opp;
}
system.debug('No of Tasks'+inp+inr);
}
when trying to create a task on an opportunity I get the the following error:
CountTask: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id 0065800000MKq82AAD; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] Trigger.CountTask: line 32, column 1
Since I am a bit new with Apex triggers, could someone explain, what do I need to do to fix this?
Thank you very much in advance
Debug Log:
30.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
16:28:44.2 (2103082)|ENTERING_MANAGED_PKG|APXTConga4
16:28:44.2 (11606583)|SOQL_EXECUTE_BEGIN|[46]|Aggregations:0|SELECT id, APXTConga4__WhatId__c FROM APXTConga4__Conga_Email_Staging__c
16:28:44.2 (17655073)|SOQL_EXECUTE_END|[46]|Rows:0
16:28:44.18 (18693349)|CUMULATIVE_LIMIT_USAGE
16:28:44.18 (18693349)|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.18 (18693349)|LIMIT_USAGE_FOR_NS|APXTConga4|
Number of SOQL queries: 1 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.18 (18693349)|CUMULATIVE_LIMIT_USAGE_END
16:28:44.166 (166843648)|CODE_UNIT_STARTED|[EXTERNAL]|01q3E000000CzBl|Counttasks on Task trigger event AfterInsert for [00T3E000006N4P7]
16:28:44.166 (166926635)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
16:28:44.166 (167097773)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:10
16:28:44.166 (167215648)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:28
16:28:44.166 (167237693)|VARIABLE_SCOPE_BEGIN|[1]|this|Counttasks|true|false
16:28:44.166 (167316006)|VARIABLE_ASSIGNMENT|[1]|this|{}|0xba5e15e
16:28:44.166 (167401981)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:28
16:28:44.166 (167726154)|VARIABLE_SCOPE_BEGIN|[1]|this|Counttasks|true|false
16:28:44.166 (167769513)|VARIABLE_ASSIGNMENT|[1]|this|{}|0xba5e15e
16:28:44.166 (167782415)|STATEMENT_EXECUTE|[1]
16:28:44.166 (167784464)|STATEMENT_EXECUTE|[3]
16:28:44.166 (167814696)|HEAP_ALLOCATE|[3]|Bytes:4
16:28:44.166 (167882366)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
16:28:44.166 (167897985)|VARIABLE_ASSIGNMENT|[3]|this.ltask1|[]|0xba5e15e
16:28:44.166 (167904053)|STATEMENT_EXECUTE|[4]
16:28:44.166 (167916662)|VARIABLE_ASSIGNMENT|[4]|this.oppid|null|0xba5e15e
16:28:44.166 (167922885)|STATEMENT_EXECUTE|[5]
16:28:44.166 (167930867)|HEAP_ALLOCATE|[5]|Bytes:4
16:28:44.166 (167940385)|VARIABLE_ASSIGNMENT|[5]|this.inp|0|0xba5e15e
16:28:44.166 (167945619)|STATEMENT_EXECUTE|[6]
16:28:44.166 (167951062)|HEAP_ALLOCATE|[6]|Bytes:4
16:28:44.166 (167959200)|VARIABLE_ASSIGNMENT|[6]|this.inr|0|0xba5e15e
16:28:44.166 (168076642)|HEAP_ALLOCATE|[7]|Bytes:5
16:28:44.166 (168163019)|VARIABLE_SCOPE_BEGIN|[7]|t|Task|true|false
16:28:44.166 (183115571)|VARIABLE_ASSIGNMENT|[7]|t|{"LastModifiedDate":"2017-10-23T14:28:44.000Z","AccountId":"0015800000rcsReAAI","WhatId":"0065800000MKq82AAD","WhatCount":1,"IsHighPriority":false,"IsClosed":false,"WhoCount":0,"CreatedById":"00558000001scKvAAI","OwnerId":"00558000001scKvAAI","RecordTypeId":"01258000000cf60AAA","IsReminderSet":false,"CallAttptDateVa__c":"2017-10-23T14:28:44.000Z","Agent_ID__c":"00558000001scKv","Status":"Offen","QualifiedVa__c":false,"IsDeleted":false,"ActivityDate":"2017-10-27T00:00:00.000Z","Priority":"Normal","Qualified__c":false,"CurrencyIsoCode":"EUR","IsRecurrence":false,"Subject":"Test task","SystemModstamp":"2017-10-23T14:28:44.000Z","IsArchived":false,"Overdue_Task__c":"Not yet due","TaskSubtype":"Task","CreatedDate":"2017-10-23T14:28:44.000Z","Id":"00T3E000006N4P7UAK","etreminder__Reminder (3 more) ...":false,"LastModifiedById":"00558000001scKvAAI"}|0x4b02ac77
16:28:44.166 (183156343)|STATEMENT_EXECUTE|[7]
16:28:44.166 (183158555)|STATEMENT_EXECUTE|[8]
16:28:44.166 (183418924)|VARIABLE_ASSIGNMENT|[8]|this.oppid|"0065800000MKq82AAD"|0xba5e15e
16:28:44.166 (183428932)|STATEMENT_EXECUTE|[9]
16:28:44.166 (183436148)|HEAP_ALLOCATE|[9]|Bytes:5
16:28:44.166 (183536527)|HEAP_ALLOCATE|[9]|Bytes:18
16:28:44.166 (183599211)|HEAP_ALLOCATE|[9]|Bytes:23
16:28:44.166 (183637592)|USER_DEBUG|[9]|DEBUG|oppid0065800000MKq82AAD
16:28:44.166 (183674707)|HEAP_ALLOCATE|[7]|Bytes:5
16:28:44.166 (183707930)|VARIABLE_ASSIGNMENT|[7]|t|null|
16:28:44.166 (183720883)|STATEMENT_EXECUTE|[12]
16:28:44.166 (183726941)|HEAP_ALLOCATE|[12]|Bytes:51
16:28:44.166 (183759355)|HEAP_ALLOCATE|[12]|Bytes:4
16:28:44.166 (184248439)|SOQL_EXECUTE_BEGIN|[12]|Aggregations:0|SELECT id, Status FROM task WHERE whatid = :tmpVar1
16:28:44.166 (210054678)|SOQL_EXECUTE_END|[12]|Rows:1
16:28:44.166 (210102431)|HEAP_ALLOCATE|[12]|Bytes:8
16:28:44.166 (210127862)|HEAP_ALLOCATE|[12]|Bytes:44
16:28:44.166 (210190225)|HEAP_ALLOCATE|[12]|Bytes:8
16:28:44.166 (210271650)|VARIABLE_ASSIGNMENT|[12]|this.ltask1|[{"Id":"00T3E000006N4P7UAK","Status":"Offen"}]|0xba5e15e
16:28:44.166 (210283838)|STATEMENT_EXECUTE|[13]
16:28:44.166 (210291150)|HEAP_ALLOCATE|[13]|Bytes:7
16:28:44.166 (210392442)|HEAP_ALLOCATE|[13]|Bytes:1
16:28:44.166 (210413354)|HEAP_ALLOCATE|[13]|Bytes:8
16:28:44.166 (210430785)|USER_DEBUG|[13]|DEBUG|oppsize1
16:28:44.166 (210511107)|HEAP_ALLOCATE|[16]|Bytes:5
16:28:44.166 (210548229)|HEAP_ALLOCATE|[16]|Bytes:12
16:28:44.166 (210568605)|VARIABLE_SCOPE_BEGIN|[16]|t|Task|true|false
16:28:44.166 (210591779)|VARIABLE_ASSIGNMENT|[16]|t|{"Id":"00T3E000006N4P7UAK","Status":"Offen"}|0x1f929a41
16:28:44.166 (210601216)|STATEMENT_EXECUTE|[16]
16:28:44.166 (210637116)|HEAP_ALLOCATE|[17]|Bytes:9
16:28:44.166 (210670079)|STATEMENT_EXECUTE|[17]
16:28:44.166 (210671997)|STATEMENT_EXECUTE|[18]
16:28:44.166 (210686339)|HEAP_ALLOCATE|[18]|Bytes:4
16:28:44.166 (210699455)|VARIABLE_ASSIGNMENT|[18]|this.inp|1|0xba5e15e
16:28:44.166 (210717258)|HEAP_ALLOCATE|[16]|Bytes:5
16:28:44.166 (210733116)|VARIABLE_ASSIGNMENT|[16]|t|null|
16:28:44.166 (210745375)|STATEMENT_EXECUTE|[23]
16:28:44.166 (210778777)|HEAP_ALLOCATE|[23]|Bytes:4
16:28:44.166 (210859430)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
16:28:44.166 (210872795)|VARIABLE_ASSIGNMENT|[23]|this.opp|[]|0xba5e15e
16:28:44.166 (210879797)|STATEMENT_EXECUTE|[24]
16:28:44.166 (210883638)|HEAP_ALLOCATE|[24]|Bytes:46
16:28:44.166 (210901808)|HEAP_ALLOCATE|[24]|Bytes:4
16:28:44.166 (211225629)|SOQL_EXECUTE_BEGIN|[24]|Aggregations:0|SELECT id FROM Opportunity WHERE id = :tmpVar1
16:28:44.166 (228382474)|SOQL_EXECUTE_END|[24]|Rows:1
16:28:44.166 (228423557)|HEAP_ALLOCATE|[24]|Bytes:8
16:28:44.166 (228445757)|HEAP_ALLOCATE|[24]|Bytes:29
16:28:44.166 (228509663)|HEAP_ALLOCATE|[24]|Bytes:8
16:28:44.166 (228590026)|VARIABLE_ASSIGNMENT|[24]|this.op|[{"Id":"0065800000MKq82AAD"}]|0xba5e15e
16:28:44.166 (228602917)|STATEMENT_EXECUTE|[25]
16:28:44.166 (228699301)|HEAP_ALLOCATE|[25]|Bytes:1
16:28:44.166 (228720486)|HEAP_ALLOCATE|[25]|Bytes:8
16:28:44.166 (228757069)|USER_DEBUG|[25]|DEBUG|oppsize1
16:28:44.166 (228950342)|HEAP_ALLOCATE|[26]|Bytes:5
16:28:44.166 (228986680)|HEAP_ALLOCATE|[26]|Bytes:8
16:28:44.166 (229004080)|VARIABLE_SCOPE_BEGIN|[26]|o|Opportunity|true|false
16:28:44.166 (229024855)|VARIABLE_ASSIGNMENT|[26]|o|{"Id":"0065800000MKq82AAD"}|0x3cd4bd33
16:28:44.166 (229032667)|STATEMENT_EXECUTE|[26]
16:28:44.166 (229034029)|STATEMENT_EXECUTE|[27]
16:28:44.166 (229080362)|HEAP_ALLOCATE|[27]|Bytes:28
16:28:44.166 (229087921)|HEAP_ALLOCATE|[27]|Bytes:28
16:28:44.166 (229148700)|HEAP_ALLOCATE|[27]|Bytes:-4
16:28:44.166 (229165722)|VARIABLE_ASSIGNMENT|[27]|this.Open_Tasks__c|1|0x3cd4bd33
16:28:44.166 (229171858)|STATEMENT_EXECUTE|[28]
16:28:44.166 (229190966)|HEAP_ALLOCATE|[28]|Bytes:28
16:28:44.166 (229197103)|HEAP_ALLOCATE|[28]|Bytes:28
16:28:44.166 (229229141)|HEAP_ALLOCATE|[28]|Bytes:-4
16:28:44.166 (229240584)|VARIABLE_ASSIGNMENT|[28]|this.Closed_Tasks__c|0|0x3cd4bd33
16:28:44.166 (229246898)|STATEMENT_EXECUTE|[29]
16:28:44.166 (229295763)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
16:28:44.166 (229331151)|HEAP_ALLOCATE|[26]|Bytes:5
16:28:44.166 (229351385)|VARIABLE_ASSIGNMENT|[26]|o|null|
16:28:44.166 (229392780)|STATEMENT_EXECUTE|[31]
16:28:44.166 (229396733)|STATEMENT_EXECUTE|[32]
16:28:44.166 (229472763)|DML_BEGIN|[32]|Op:Update|Type:Opportunity|Rows:1
16:28:44.166 (229520965)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
16:28:44.320 (320138761)|ENTERING_MANAGED_PKG|Five9LSP
16:28:44.320 (325816235)|ENTERING_MANAGED_PKG|Five9LSP
16:28:44.320 (325879741)|ENTERING_MANAGED_PKG|Five9LSP
16:28:44.320 (326061566)|ENTERING_MANAGED_PKG|Five9LSP
16:28:44.332 (332314872)|CUMULATIVE_LIMIT_USAGE
16:28:44.332 (332314872)|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 2 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 1 out of 150
Number of DML rows: 1 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.332 (332314872)|LIMIT_USAGE_FOR_NS|APXTConga4|
Number of SOQL queries: 1 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.332 (332314872)|CUMULATIVE_LIMIT_USAGE_END
16:28:44.166 (337368997)|CODE_UNIT_STARTED|[EXTERNAL]|01q58000000eNwB|OpportunityTrigger on Opportunity trigger event BeforeUpdate for [0065800000MKq82]
16:28:44.166 (337404714)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
16:28:44.166 (337413925)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
16:28:44.166 (337458882)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
16:28:44.166 (337472388)|VARIABLE_SCOPE_BEGIN|[1]|this|OpportunityTrigger|true|false
16:28:44.166 (337540283)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x79af66c3
16:28:44.166 (337586081)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
16:28:44.166 (337598233)|VARIABLE_SCOPE_BEGIN|[1]|this|OpportunityTrigger|true|false
16:28:44.166 (337614878)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x79af66c3
16:28:44.166 (337623491)|STATEMENT_EXECUTE|[1]
16:28:44.166 (337637315)|STATEMENT_EXECUTE|[3]
16:28:44.166 (337646669)|STATEMENT_EXECUTE|[6]
16:28:44.337 (337650964)|CUMULATIVE_LIMIT_USAGE
16:28:44.337 (337650964)|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 2 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 1 out of 150
Number of DML rows: 1 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.337 (337650964)|LIMIT_USAGE_FOR_NS|APXTConga4|
Number of SOQL queries: 1 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.337 (337650964)|CUMULATIVE_LIMIT_USAGE_END
16:28:44.166 (339259338)|CODE_UNIT_FINISHED|OpportunityTrigger on Opportunity trigger event BeforeUpdate for [0065800000MKq82]
16:28:44.166 (389961988)|DML_END|[32]
16:28:44.166 (390113032)|EXCEPTION_THROWN|[32]|System.DmlException: Update failed. First exception on row 0 with id 0065800000MKq82AAD; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []
16:28:44.166 (390843952)|HEAP_ALLOCATE|[32]|Bytes:144
16:28:44.166 (391119104)|FATAL_ERROR|System.DmlException: Update failed. First exception on row 0 with id 0065800000MKq82AAD; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []
Trigger.Counttasks: line 32, column 1
16:28:44.166 (391137831)|FATAL_ERROR|System.DmlException: Update failed. First exception on row 0 with id 0065800000MKq82AAD; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []
Trigger.Counttasks: line 32, column 1
16:28:44.391 (391143142)|CUMULATIVE_LIMIT_USAGE
16:28:44.391 (391143142)|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 2 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 1 out of 150
Number of DML rows: 1 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.391 (391143142)|LIMIT_USAGE_FOR_NS|APXTConga4|
Number of SOQL queries: 1 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
16:28:44.391 (391143142)|CUMULATIVE_LIMIT_USAGE_END
- Efstathios Ntatsios 6
- October 24, 2017
- Like
- 0
Apex Trigger to Count Activities on Opportunity
Below is a trigger I wrote to sum the number of activities on a given opportunity. I am getting an error at line 20, unexpected token: 'Map'.
Any ideas on what I could be doing wrong? This is the first trigger I have written so go easy on me :)
trigger CountTasks on Opportunity (before update) {
// Put all Opportunities into a Set
Set<string> allOppIDs = new Set<string>();
for (Opportunity newOpp : Trigger.new) {
allOppIDs.add(newOpp.ID);
System.debug('ID added: ' + newOpp.ID);
}
//Query All Tasks to find Tasks with matching IDs
List<task> allTasks = [SELECT Id, Status, WhatID from Task
WHERE WhatID IN :allOppIDs];
System.debug('allTasks is ' + allTasks.size());
// Create a Map that lets you search for Tasks by their ID - faster than SOQL each time
List<string> TaskArray = new List<string>(); //All Tasks
List<string> IDToTaskMapOpen = new List<string>(); //usedforOpenTasks
List<string> IDToTaskMapClosed = new List<string>(); //usedforClosedTasks
Map<string nteger=""> elCountAll = new Map<string nteger="">(); //Count of All Tasks
Map<string nteger=""> elCountOpen = new Map<string nteger="">(); //Count of Open Tasks
Map<string nteger=""> elCountClosed = new Map<string nteger="">(); //Count of Closed Tasks
for (Task u : allTasks) {
if (u.Status != 'Completed' ) {
IDToTaskMapOpen.add(u.WhatID);
System.debug('Added Open Task');
}
if (u.Status == 'Completed') {
System.debug('Added Completed Task');
IDToTaskMapClosed.add(u.WhatID);
}
TaskArray.add(u.WhatID);
}
System.debug(allTasks.size());
System.debug(IDToTaskMapOpen.size());
System.debug(IDToTaskMapClosed.size());
// Get the matching tasks from the Map - and count Status
//Start with our Opportunity
for (Opportunity newOpp : Trigger.new) {
//Count all Tasks
for(String key : TaskArray)
{
if(!elCountAll.containsKey(key)){
elCountAll.put(key,0);
}
Integer currentInt=elCountAll.get(key)+1;
elCountAll.put(key,currentInt);
}
//Count all Open Tasks
for(String key1 : IDToTaskMapOpen)
{
if(!elCountOpen.containsKey(key1)){
elCountOpen.put(key1,0);
}
Integer currentInt1=elCountOpen.get(key1)+1;
elCountOpen.put(key1,currentInt1);
}
//Count all Closed Tasks
for(String key2 : IDToTaskMapClosed)
{
if(!elCountClosed.containsKey(key2)){
elCountClosed.put(key2,0);
}
Integer currentInt2=elCountClosed.get(key2)+1;
elCountClosed.put(key2,currentInt2);
}
//Finally update the record
//All Activities
newOpp.AllTasks__c = elCountAll.get(newOpp.ID);
//Open & Not Started Tasks
newOpp.Open_Tasks__c = elCountOpen.get(newOpp.ID);
//Closed Tasks
newOpp.Closed_Tasks__c = elCountClosed.get(newOpp.ID);
}
}
</string></string></string></string></string></string></string></string></string></string></string></string></task></string></string>
- Chad Reynolds
- November 10, 2016
- Like
- 0