You need to sign in to do that
Don't have an account?
Jeff Bomar
Help with NullPointerException in apex trigger
Please help I created an Apex Trigger to update a field if the total testing hours change below is the error I get.
CalculateBalanceOfCustom: execution of BeforeUpdate caused by: System.NullPointerException: Argument cannot be null.: Trigger.CalculateBalanceOfCustom: line 25, column 1".
Code:
trigger CalculateBalanceOfCustom on Custom_Programming__c (before insert, before update)
{
//SQL statement to lookup price
List<PricebookEntry> Pbe = [SELECT UnitPrice FROM PricebookEntry WHERE Product2.Name IN('Custom Development','Tape Drop')AND PriceBook2.Name='DAKCS'];
//New Values for loop
for (Custom_Programming__c cp:Trigger.new)
{
//Map old Values and ID
Custom_Programming__c oldcp = Trigger.oldMap.get(cp.ID);
//Tapedrop
if (cp.Custom_Type__c == 'Tape Drop' && cp.Total_Hours__c !=oldcp.Total_Hours__c)
{
cp.Testing_Balance__c = pbe[1].UnitPrice + (pbe[0].UnitPrice * cp.Total_Hours__c);
}
//No Billing Bug Fix
if (cp.Custom_Type__c =='No Billing' || cp.Custom_Type__c =='Bug Fix'&& cp.Total_Hours__c !=oldcp.Total_Hours__c)
{
cp.Testing_Balance__c = pbe[0].UnitPrice * 0;
}
//Everything Else
if (cp.Custom_Type__c !='No Billing' || cp.Custom_Type__c !='Bug Fix' || cp.Custom_Type__c!='Tape Drop' && cp.Total_Hours__c !=oldcp.Total_Hours__c)
{
cp.Testing_Balance__c =pbe[0].UnitPrice * cp.Total_Hours__c;
}
}
}
Thanks for any assistance you can give.
CalculateBalanceOfCustom: execution of BeforeUpdate caused by: System.NullPointerException: Argument cannot be null.: Trigger.CalculateBalanceOfCustom: line 25, column 1".
Code:
trigger CalculateBalanceOfCustom on Custom_Programming__c (before insert, before update)
{
//SQL statement to lookup price
List<PricebookEntry> Pbe = [SELECT UnitPrice FROM PricebookEntry WHERE Product2.Name IN('Custom Development','Tape Drop')AND PriceBook2.Name='DAKCS'];
//New Values for loop
for (Custom_Programming__c cp:Trigger.new)
{
//Map old Values and ID
Custom_Programming__c oldcp = Trigger.oldMap.get(cp.ID);
//Tapedrop
if (cp.Custom_Type__c == 'Tape Drop' && cp.Total_Hours__c !=oldcp.Total_Hours__c)
{
cp.Testing_Balance__c = pbe[1].UnitPrice + (pbe[0].UnitPrice * cp.Total_Hours__c);
}
//No Billing Bug Fix
if (cp.Custom_Type__c =='No Billing' || cp.Custom_Type__c =='Bug Fix'&& cp.Total_Hours__c !=oldcp.Total_Hours__c)
{
cp.Testing_Balance__c = pbe[0].UnitPrice * 0;
}
//Everything Else
if (cp.Custom_Type__c !='No Billing' || cp.Custom_Type__c !='Bug Fix' || cp.Custom_Type__c!='Tape Drop' && cp.Total_Hours__c !=oldcp.Total_Hours__c)
{
cp.Testing_Balance__c =pbe[0].UnitPrice * cp.Total_Hours__c;
}
}
}
Thanks for any assistance you can give.
trigger CalculateBalanceOfCustom on Custom_Programming__c (before update)
{
//SQL statement to lookup price
List<PricebookEntry> Pbe = [SELECT UnitPrice FROM PricebookEntry WHERE Product2.Name IN('Custom Development','Tape Drop')AND PriceBook2.Name='DAKCS'];
//New Values for loop
for (Custom_Programming__c cp:Trigger.new){
//Old record values
Custom_Programming__c oldcp = Trigger.oldMap.get(cp.ID);
//If total hours or custom type has not changed then bail
if(cp.Total_Hours__c==null || (cp.Total_Hours__c==oldcp.Total_Hours__c && cp.Custom_Type__c == oldcp.Custom_Type__c))
continue;
//Tapedrop3
if (cp.Custom_Type__c == 'Tape Drop')
{
cp.Testing_Balance__c = pbe[1].UnitPrice + (pbe[0].UnitPrice * cp.Total_Hours__c);
}
//No Billing Bug Fix
else if (cp.Custom_Type__c =='No Billing' || cp.Custom_Type__c =='Bug Fix')
{
cp.Testing_Balance__c = 0;
}
//Everything Else
else
{
cp.Testing_Balance__c =pbe[0].UnitPrice * cp.Total_Hours__c;
}
}
}
All Answers
I see that line 25 is
cp.Testing_Balance__c =pbe[0].UnitPrice * cp.Total_Hours__c;
The best way to identify what value is null is to add system.debug() statements in every block of your code. With this you should be able to identify the argument that is null
This post gives good example of this error message https://salesforce.stackexchange.com/questions/45382/system-nullpointerexception-argument-cannot-be-null
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
50.0
08:13:24.0 (4703059)|SOQL_EXECUTE_BEGIN|[4]|Aggregations:0|SELECT UnitPrice FROM PricebookEntry WHERE (Product2.Name IN ('Custom Development', 'Tape Drop') AND PriceBook2.Name = 'DAKCS')
08:13:24.0 (18055585)|VARIABLE_ASSIGNMENT|[4]|this.Pbe|[{"UnitPrice":185.00,"Product2Id":"01t50000002rrM5AAI","Pricebook2Id":"01s500000007M5rAAE","Id":"01u5000000GP2HMAA1"},{"UnitPrice":750.00,"Product2Id":"01t290000055CisAAE","Pricebook2Id":"01s500000007M5rAAE","Id":"01u290000085R3VAAU"}]|0x340314e0
08:13:24.0 (18679493)|VARIABLE_SCOPE_BEGIN|[6]|cp|Custom_Programming__c|true|false
08:13:24.0 (46103498)|VARIABLE_ASSIGNMENT|[6]|cp|{"LastModifiedDate":"2020-11-25T14:54:11.000Z","DSN__c":"9999","Custom_State__c":"Active","Total_Hours__c":6.0,"Program_Hours__c":6.0,"Name":"Testing","Expedite_Days__c":5,"Testing_Balance__c":185.00,"OwnerId":"00550000006JDH2AAO","CreatedById":"00550000006JDH2AAO","Amount_Billed__c":935.00,"Programmer__c":" ","Expedited__c":false,"Estimated_Bill_Date_Month__c":"/","Hourly_Cost__c":185.00,"Base_Cost__c":935.00,"Signer__c":" ","Menu_Options__c":"345","HyperLink__c":"_HL_ENCODED_file://_ (21 more) ...","IsDeleted":false,"Expedite_Amount__c":467.50,"Custom_Number__c":"C-500241","Date_Started__c":"2020-11-24T00:00:00.000Z","SystemModstamp":"2020-11-25T14:54:11.000Z","Support_Increase__c":23.38,"CreatedDate":"2020-11-24T20:48:00.000Z","Account__c":"0012900000axKI9AAM","Id":"a0J290000022qk0EAA","Status__c":"NEW","ANA_Assigned__c":"2020-11-24T00:00:00.000Z","Custom_Type__c":"Tape Drop","Requested_By__c":" ","LastModifiedById":"00550000006JDH2AAO","Creator__c":"Jeff Bomar"}|0x1db176fd
08:13:24.0 (46466976)|VARIABLE_SCOPE_BEGIN|[9]|oldcp|Custom_Programming__c|true|false
08:13:24.0 (49175070)|VARIABLE_ASSIGNMENT|[9]|oldcp|{"LastModifiedDate":"2020-11-25T14:54:11.000Z","DSN__c":"9999","Custom_State__c":"Active","Total_Hours__c":1.0,"Program_Hours__c":1.0,"Name":"Testing","Expedite_Days__c":5,"Testing_Balance__c":185.00,"OwnerId":"00550000006JDH2AAO","CreatedById":"00550000006JDH2AAO","Amount_Billed__c":935.00,"Programmer__c":" ","Expedited__c":false,"Estimated_Bill_Date_Month__c":"/","Hourly_Cost__c":185.00,"Base_Cost__c":935.00,"Signer__c":" ","Menu_Options__c":"345","HyperLink__c":"_HL_ENCODED_file://_ (21 more) ...","IsDeleted":false,"Expedite_Amount__c":467.50,"Custom_Number__c":"C-500241","Date_Started__c":"2020-11-24T00:00:00.000Z","SystemModstamp":"2020-11-25T14:54:11.000Z","Support_Increase__c":23.38,"CreatedDate":"2020-11-24T20:48:00.000Z","Account__c":"0012900000axKI9AAM","Id":"a0J290000022qk0EAA","Status__c":"NEW","ANA_Assigned__c":"2020-11-24T00:00:00.000Z","Custom_Type__c":"Tape Drop","Requested_By__c":" ","LastModifiedById":"00550000006JDH2AAO","Creator__c":"Jeff Bomar"}|0x13ba08d7
08:13:24.0 (49235587)|HEAP_ALLOCATE|[12]|Bytes:9
08:13:24.0 (49425159)|STATEMENT_EXECUTE|[13]
08:13:24.0 (49429024)|STATEMENT_EXECUTE|[14]
08:13:24.0 (49543790)|HEAP_ALLOCATE|[14]|Bytes:20
08:13:24.0 (49610196)|HEAP_ALLOCATE|[14]|Bytes:20
08:13:24.0 (49688383)|HEAP_ALLOCATE|[14]|Bytes:28
08:13:24.0 (49735831)|HEAP_ALLOCATE|[14]|Bytes:28
08:13:24.0 (51196853)|VARIABLE_ASSIGNMENT|[14]|this.Testing_Balance__c|1860.000|0x1db176fd
08:13:24.0 (51362683)|USER_DEBUG|[16]|DEBUG|***new Hours:6.0
08:13:24.0 (51472744)|USER_DEBUG|[17]|DEBUG|***old Hours:1.0
08:13:24.0 (51610733)|USER_DEBUG|[18]|DEBUG|***PriceBook inedex 1:750.00
08:13:24.0 (51745434)|USER_DEBUG|[19]|DEBUG|***PriceBook inedex 0:185.00
08:13:24.0 (53281600)|VARIABLE_ASSIGNMENT|[30]|this.Testing_Balance__c|1110.000|0x1db176fd
08:13:24.0 (53323380)|HEAP_ALLOCATE|[6]|Bytes:5
08:13:24.0 (53352385)|VARIABLE_ASSIGNMENT|[6]|cp|null|
08:13:24.53 (53378141)|CUMULATIVE_LIMIT_USAGE
08:13:24.53 (53378141)|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 1 out of 100
Number of query rows: 2 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of Publish Immediate DML: 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
08:13:24.53 (53378141)|CUMULATIVE_LIMIT_USAGE_END
08:13:24.0 (54781669)|CODE_UNIT_FINISHED|CalculateBalanceOfCustom on Custom_Programming trigger event BeforeUpdate|__sfdc_trigger/CalculateBalanceOfCustom
08:13:24.0 (80532731)|CODE_UNIT_STARTED|[EXTERNAL]|01q290000005gIZ|CustomProgrammingTriggerHandler on Custom_Programming trigger event AfterUpdate|__sfdc_trigger/CustomProgrammingTriggerHandler
08:13:24.0 (80611858)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
08:13:24.0 (80670937)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
08:13:24.0 (80841982)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
08:13:24.0 (80867850)|VARIABLE_SCOPE_BEGIN|[1]|this|CustomProgrammingTriggerHandler|true|false
08:13:24.0 (80924811)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x39b52616
08:13:24.0 (81002062)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
08:13:24.0 (81018667)|VARIABLE_SCOPE_BEGIN|[1]|this|CustomProgrammingTriggerHandler|true|false
08:13:24.0 (81041089)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x39b52616
08:13:24.0 (81053521)|STATEMENT_EXECUTE|[1]
08:13:24.0 (81082190)|STATEMENT_EXECUTE|[3]
08:13:24.0 (81095923)|STATEMENT_EXECUTE|[6]
08:13:24.0 (81098074)|STATEMENT_EXECUTE|[7]
08:13:24.0 (83786081)|HEAP_ALLOCATE|[7]|Bytes:5
08:13:24.0 (83834231)|METHOD_ENTRY|[1]|01p29000000phrj|CustomProgrammingTriggerHandler.CustomProgrammingTriggerHandler()
08:13:24.0 (83844975)|STATEMENT_EXECUTE|[1]
08:13:24.0 (83850288)|STATEMENT_EXECUTE|[1]
08:13:24.0 (83862928)|METHOD_EXIT|[1]|CustomProgrammingTriggerHandler
08:13:24.0 (83909551)|METHOD_ENTRY|[7]|01p29000000phrj|CustomProgrammingTriggerHandler.onAfterUpdate(List<Custom_Programming__c>, Map<Id,Custom_Programming__c>)
08:13:24.0 (83957517)|VARIABLE_SCOPE_BEGIN|[4]|newList|List<Custom_Programming__c>|true|false
08:13:24.0 (87192557)|VARIABLE_ASSIGNMENT|[4]|newList|[{"LastModifiedDate":"2020-11-25T15:13:24.000Z","DSN__c":"9999","Custom_State__c":"Active","Total_Hours__c":6.0,"Program_Hours__c":6.0,"Name":"Testing","Expedite_Days__c":5,"Testing_Balance__c":1110.00,"OwnerId":"00550000006JDH2AAO","CreatedById":"00550000006JDH2AAO","Amount_Billed__c":935.00,"Programmer__c":" ","Expedited__c":false,"Estimated_Bill_Date_Month__c":"/","Hourly_Cost__c":185.00,"Base_Cost__c":935.00,"Signer__c":" ","Menu_Options__c":"345","HyperLink__c":"_HL_ENCODED_file://_ (21 more) ...","IsDeleted":false,"Expedite_Amount__c":467.50,"Custom_Number__c":"C-500241","Date_Started__c":"2020-11-24T00:00:00.000Z","SystemModstamp":"2020-11-25T15:13:24.000Z","Support_Increase__c":23.38,"CreatedDate":"2020-11-24T20:48:00.000Z","Account__c":"0012900000axKI9AAM","Id":"a0J290000022qk0EAA","Status__c":"NEW","ANA_Assigned__c":"2020-11-24T00:00:00.000Z","Custom_Type__c":"Tape Drop","Requested_By__c":" ","LastModifiedById":"00550000006JDH2AAO","Creator__c":"Jeff Bomar"}]|0x15393c53
08:13:24.0 (87222868)|VARIABLE_SCOPE_BEGIN|[4]|oldmap|Map<Id,Custom_Programming__c>|true|false
08:13:24.0 (91420103)|VARIABLE_ASSIGNMENT|[4]|oldmap|{"a0J290000022qk0EAA":{"LastModifiedDate":"2020-11-25T14:54:11.000Z","DSN__c":"9999","Custom_State__c":"Active","Total_Hours__c":1.0,"Program_Hours__c":1.0,"Name":"Testing","Expedite_Days__c":5,"Testing_Balance__c":185.00,"OwnerId":"00550000006JDH2AAO","CreatedById":"00550000006JDH2AAO","Amount_Billed__c":935.00,"Programmer__c":" ","Expedited__c":false,"Estimated_Bill_Date_Month__c":"/","Hourly_Cost__c":185.00,"Base_Cost__c":935.00,"Signer__c":" ","Menu_Options__c":"345","HyperLink__c":"_HL_ENCODED_file://_ (21 more) ...","IsDeleted":false,"Expedite_Amount__c":467.50,"Custom_Number__c":"C-500241","Date_Started__c":"2020-11-24T00:00:00.000Z","SystemModstamp":"2020-11-25T14:54:11.000Z","Support_Increase__c":23.38,"CreatedDate":"2020-11-24T20:48:00.000Z","Account__c":"0012900000axKI9AAM","Id":"a0J290000022qk0EAA","Status__c":"NEW","ANA_Assigned__c":"2020-11-24T00:00:00.000Z","Custom_Type__c":"Tape Drop","Requested_By__c":" ","LastModifiedById":"00550000006JDH2AAO","Creator__c":"Jeff Bomar"}}|0x3129d6a4
08:13:24.0 (91449751)|STATEMENT_EXECUTE|[4]
08:13:24.0 (91468614)|METHOD_EXIT|[7]|01p29000000phrj|CustomProgrammingTriggerHandler.onAfterUpdate(List<Custom_Programming__c>, Map<Id,Custom_Programming__c>)
08:13:24.91 (91487232)|CUMULATIVE_LIMIT_USAGE
08:13:24.91 (91487232)|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 1 out of 100
Number of query rows: 2 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of Publish Immediate DML: 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
08:13:24.91 (91487232)|CUMULATIVE_LIMIT_USAGE_END
08:13:24.0 (92768777)|CODE_UNIT_FINISHED|CustomProgrammingTriggerHandler on Custom_Programming trigger event AfterUpdate|__sfdc_trigger/CustomProgrammingTriggerHandler
08:13:24.0 (93905724)|CODE_UNIT_STARTED|[EXTERNAL]|Workflow:01I1T0000012EP3
08:13:24.0 (100642315)|WF_RULE_EVAL_BEGIN|Workflow
08:13:24.0 (100695007)|WF_CRITERIA_BEGIN|[Custom Programming: Testing a0J290000022qk0]|Update_Custom_Account3011T000000Uk9D|01Q1T00000098CN|ON_RECURSIVE_UPDATE|0
08:13:24.0 (100990051)|WF_FORMULA|Formula:ENCODED:[treatNullAsNull]true|Values:
08:13:24.0 (101002827)|WF_CRITERIA_END|true
08:13:24.0 (101653569)|WF_CRITERIA_BEGIN|[Custom Programming: Testing a0J290000022qk0]|Analysis Programmer Update|01Q1T00000097yG|ON_ALL_CHANGES|0
08:13:24.0 (102314328)|WF_FORMULA|Formula:ENCODED:[treatNullAsNull]ISCHANGED({!ID:00N1T00000Al8XN})|Values:Analysis__c=
08:13:24.0 (102332079)|WF_CRITERIA_END|false
08:13:24.0 (102349178)|WF_CRITERIA_BEGIN|[Custom Programming: Testing a0J290000022qk0]|Expedited Update|01Q1T0000009807|ON_ALL_CHANGES|0
08:13:24.0 (102725410)|WF_FORMULA|Formula:ENCODED:[treatNullAsNull]ISCHANGED({!ID:00N1T00000Al8Vv})|Values:Expedited__c=0
08:13:24.0 (102739990)|WF_CRITERIA_END|false
08:13:24.0 (102755213)|WF_CRITERIA_BEGIN|[Custom Programming: Testing a0J290000022qk0]|Update total hours|01Q1T000000TmjJ|ON_ALL_CHANGES|0
08:13:24.0 (103420419)|WF_FORMULA|Formula:ENCODED:[treatNullAsNull]ISCHANGED({!ID:00N1T00000Al8WU}) || ISCHANGED({!ID:00N1T00000Al8WP}) || ISCHANGED({!ID:00N1T00000Al8WZ})|Values:Program_Hours__c=6.0, Analysis_Hours__c=null, Test_Hours__c=null
08:13:24.0 (103435580)|WF_CRITERIA_END|true
08:13:24.0 (103457559)|WF_CRITERIA_BEGIN|[Custom Programming: Testing a0J290000022qk0]|Sent Job Order|01Q1T00000097ux|ON_ALL_CHANGES|0
08:13:24.0 (104045006)|WF_FORMULA|Formula:ENCODED:[treatNullAsNull]ISCHANGED({!ID:00N1T00000Al8Ud}) && ISPICKVAL({!ID:00N1T00000Al8Ud},"AWAITING JOB ORDER")|Values:Status__c=NEW
08:13:24.0 (104059281)|WF_CRITERIA_END|false
08:13:24.0 (104072887)|WF_CRITERIA_BEGIN|[Custom Programming: Testing a0J290000022qk0]|Analysis Finished Date Update|01Q1T00000097q7|ON_CREATE_OR_TRIGGERING_UPDATE|0
08:13:24.0 (109597606)|WF_RULE_FILTER|[Custom Programming : Status equals SEND ANALYSIS]
08:13:24.0 (109634320)|WF_RULE_EVAL_VALUE|1
08:13:24.0 (109647782)|WF_CRITERIA_END|false
08:13:24.0 (109672815)|WF_CRITERIA_BEGIN|[Custom Programming: Testing a0J290000022qk0]|Started Testing Update|01Q1T000000989x|ON_CREATE_OR_TRIGGERING_UPDATE|0
08:13:24.0 (110518950)|WF_FORMULA|Formula:ENCODED:[treatNullAsNull]ISPICKVAL({!ID:00N1T00000Al8Ud},"TEST" ) && ISBLANK({!ID:00N1T00000Al8Wj})|Values:Status__c=NEW, Started_Testing__c=null
08:13:24.0 (110537375)|WF_CRITERIA_END|false
08:13:24.0 (110559700)|WF_CRITERIA_BEGIN|[Custom Programming: Testing a0J290000022qk0]|Update Cost Standard|01Q1T000000TmjE|ON_ALL_CHANGES|0
08:13:24.0 (111246828)|WF_FORMULA|Formula:ENCODED:[treatNullAsNull]ISCHANGED({!ID:00N1T00000Al8We}) || ISCHANGED({!ID:00N1T00000Al8X3}) &&!ISPICKVAL({!ID:00N1T00000Al8X3},"Support Increase Only")|Values:Total_Hours__c=6.0, Custom_Type__c=Tape Drop
08:13:24.0 (111268279)|WF_CRITERIA_END|true
08:13:24.0 (111309038)|WF_CRITERIA_BEGIN|[Custom Programming: Testing a0J290000022qk0]|Analysis Date Update|01Q1T00000097q2|ON_CREATE_OR_TRIGGERING_UPDATE|0
08:13:24.0 (111409065)|WF_RULE_FILTER|[Custom Programming : Status equals ANALYSIS]
08:13:24.0 (111435496)|WF_RULE_EVAL_VALUE|1
08:13:24.0 (111446630)|WF_CRITERIA_END|false
08:13:24.0 (111467011)|WF_CRITERIA_BEGIN|[Custom Programming: Testing a0J290000022qk0]|Custom_Program_Default_Contacts3011T000000A82v|01Q1T000000Tmk7|ON_CREATE_ONLY|0
08:13:24.0 (111486756)|WF_RULE_NOT_EVALUATED
08:13:24.0 (111501745)|WF_CRITERIA_BEGIN|[Custom Programming: Testing a0J290000022qk0]|Sent Analysis|01Q1T00000097us|ON_ALL_CHANGES|0
08:13:24.0 (111978280)|WF_FORMULA|Formula:ENCODED:[treatNullAsNull]ISCHANGED({!ID:00N1T00000Al8Ud}) && ISPICKVAL({!ID:00N1T00000Al8Ud},"AWAITING ANALYSIS")|Values:Status__c=NEW
08:13:24.0 (111991874)|WF_CRITERIA_END|false
08:13:24.0 (112005193)|WF_CRITERIA_BEGIN|[Custom Programming: Testing a0J290000022qk0]|Update Code Review Date|01Q1T00000097un|ON_ALL_CHANGES|0
08:13:24.0 (112380203)|WF_FORMULA|Formula:ENCODED:[treatNullAsNull]ISCHANGED({!ID:00N1T00000AWf3u})|Values:Code_Review__c=null
08:13:24.0 (112399633)|WF_CRITERIA_END|false
08:13:24.0 (112421206)|WF_CRITERIA_BEGIN|[Custom Programming: Testing a0J290000022qk0]|Completion Date Change|01Q1T00000097ui|ON_ALL_CHANGES|0
08:13:24.0 (112938863)|WF_FORMULA|Formula:ENCODED:[treatNullAsNull]ISCHANGED({!ID:00N1T00000Al8VC}) && ISPICKVAL({!ID:00N1T00000Al8Ud},"JOB ORDER SIGNED")|Values:Status__c=NEW, Completion_Due_Date__c=null
08:13:24.0 (112962243)|WF_CRITERIA_END|false
08:13:24.0 (112991829)|WF_SPOOL_ACTION_BEGIN|Workflow
08:13:24.0 (116152491)|WF_FIELD_UPDATE|[Custom Programming: Testing a0J290000022qk0]|Field:Custom Programming: Total Hours|Value:null|Id=04Y1T000000Ru8e|CurrentRule:Update total hours (Id=01Q1T000000TmjJ)
08:13:24.0 (116295941)|WF_FIELD_UPDATE|[Custom Programming: Testing a0J290000022qk0]|Field:Custom Programming: Base Cost|Value:|Id=04Y1T000000Ru8K|CurrentRule:Update Cost Standard (Id=01Q1T000000TmjE)
08:13:24.0 (116435912)|WF_FIELD_UPDATE|[Custom Programming: Testing a0J290000022qk0]|Field:Custom Programming: Expedite Amount|Value:|Id=04Y1T000000Ru8P|CurrentRule:Update Cost Standard (Id=01Q1T000000TmjE)
08:13:24.0 (116562479)|WF_FIELD_UPDATE|[Custom Programming: Testing a0J290000022qk0]|Field:Custom Programming: Support Increase|Value:|Id=04Y1T000000Ru8U|CurrentRule:Update Cost Standard (Id=01Q1T000000TmjE)
08:13:24.0 (116746418)|WF_FIELD_UPDATE|[Custom Programming: Testing a0J290000022qk0]|Field:Custom Programming: Amount Billed|Value:|Id=04Y1T000000Ru8Z|CurrentRule:Update Cost Standard (Id=01Q1T000000TmjE)
08:13:24.0 (116909917)|WF_ACTION| Field Update: 6; Flow Trigger: 1;
08:13:24.0 (116919693)|WF_RULE_EVAL_END
08:13:24.0 (119184534)|CODE_UNIT_STARTED|[EXTERNAL]|01q290000005gNK|CalculateBalanceOfCustom on Custom_Programming trigger event BeforeUpdate|__sfdc_trigger/CalculateBalanceOfCustom
08:13:24.0 (119253554)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
08:13:24.0 (119309026)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
08:13:24.0 (119401006)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
08:13:24.0 (119422421)|VARIABLE_SCOPE_BEGIN|[1]|this|CalculateBalanceOfCustom|true|false
08:13:24.0 (119477259)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x4a2c757b
08:13:24.0 (119517965)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
08:13:24.0 (119529545)|VARIABLE_SCOPE_BEGIN|[1]|this|CalculateBalanceOfCustom|true|false
08:13:24.0 (119551131)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x4a2c757b
08:13:24.0 (119563906)|STATEMENT_EXECUTE|[1]
08:13:24.0 (119566587)|STATEMENT_EXECUTE|[4]
08:13:24.0 (119590478)|HEAP_ALLOCATE|[4]|Bytes:4
08:13:24.0 (120162369)|SOQL_EXECUTE_BEGIN|[4]|Aggregations:0|SELECT UnitPrice FROM PricebookEntry WHERE (Product2.Name IN ('Custom Development', 'Tape Drop') AND PriceBook2.Name = 'DAKCS')
08:13:24.0 (133542451)|SOQL_EXECUTE_END|[4]|Rows:2
08:13:24.0 (133602928)|HEAP_ALLOCATE|[4]|Bytes:12
08:13:24.0 (133672281)|HEAP_ALLOCATE|[4]|Bytes:288
08:13:24.0 (133740433)|HEAP_ALLOCATE|[4]|Bytes:12
08:13:24.0 (133846518)|VARIABLE_ASSIGNMENT|[4]|this.Pbe|[{"UnitPrice":185.00,"Product2Id":"01t50000002rrM5AAI","Pricebook2Id":"01s500000007M5rAAE","Id":"01u5000000GP2HMAA1"},{"UnitPrice":750.00,"Product2Id":"01t290000055CisAAE","Pricebook2Id":"01s500000007M5rAAE","Id":"01u290000085R3VAAU"}]|0x4a2c757b
08:13:24.0 (133938373)|HEAP_ALLOCATE|[6]|Bytes:5
08:13:24.0 (133981257)|HEAP_ALLOCATE|[6]|Bytes:4
08:13:24.0 (134005764)|VARIABLE_SCOPE_BEGIN|[6]|cp|Custom_Programming__c|true|false
08:13:24.0 (136850597)|VARIABLE_ASSIGNMENT|[6]|cp|{"LastModifiedDate":"2020-11-25T15:13:24.000Z","DSN__c":"9999","Custom_State__c":"Active","Program_Hours__c":6.0,"Name":"Testing","Expedite_Days__c":5,"Testing_Balance__c":1110.00,"OwnerId":"00550000006JDH2AAO","CreatedById":"00550000006JDH2AAO","Programmer__c":" ","Expedited__c":false,"Estimated_Bill_Date_Month__c":"/","Hourly_Cost__c":185.00,"Signer__c":" ","Menu_Options__c":"345","HyperLink__c":"_HL_ENCODED_file://_ (21 more) ...","IsDeleted":false,"Custom_Number__c":"C-500241","Date_Started__c":"2020-11-24T00:00:00.000Z","SystemModstamp":"2020-11-25T15:13:24.000Z","CreatedDate":"2020-11-24T20:48:00.000Z","Account__c":"0012900000axKI9AAM","Id":"a0J290000022qk0EAA","Status__c":"NEW","ANA_Assigned__c":"2020-11-24T00:00:00.000Z","Custom_Type__c":"Tape Drop","Requested_By__c":" ","LastModifiedById":"00550000006JDH2AAO","Creator__c":"Jeff Bomar"}|0x4589093a
08:13:24.0 (136877174)|STATEMENT_EXECUTE|[7]
08:13:24.0 (136879940)|STATEMENT_EXECUTE|[9]
08:13:24.0 (136963682)|VARIABLE_SCOPE_BEGIN|[9]|oldcp|Custom_Programming__c|true|false
08:13:24.0 (140991855)|VARIABLE_ASSIGNMENT|[9]|oldcp|{"LastModifiedDate":"2020-11-25T14:54:11.000Z","DSN__c":"9999","Custom_State__c":"Active","Total_Hours__c":1.0,"Program_Hours__c":1.0,"Name":"Testing","Expedite_Days__c":5,"Testing_Balance__c":185.00,"OwnerId":"00550000006JDH2AAO","CreatedById":"00550000006JDH2AAO","Amount_Billed__c":935.00,"Programmer__c":" ","Expedited__c":false,"Estimated_Bill_Date_Month__c":"/","Hourly_Cost__c":185.00,"Base_Cost__c":935.00,"Signer__c":" ","Menu_Options__c":"345","HyperLink__c":"_HL_ENCODED_file://_ (21 more) ...","IsDeleted":false,"Expedite_Amount__c":467.50,"Custom_Number__c":"C-500241","Date_Started__c":"2020-11-24T00:00:00.000Z","SystemModstamp":"2020-11-25T14:54:11.000Z","Support_Increase__c":23.38,"CreatedDate":"2020-11-24T20:48:00.000Z","Account__c":"0012900000axKI9AAM","Id":"a0J290000022qk0EAA","Status__c":"NEW","ANA_Assigned__c":"2020-11-24T00:00:00.000Z","Custom_Type__c":"Tape Drop","Requested_By__c":" ","LastModifiedById":"00550000006JDH2AAO","Creator__c":"Jeff Bomar"}|0x516b7591
08:13:24.0 (141103579)|STATEMENT_EXECUTE|[13]
08:13:24.0 (141107865)|STATEMENT_EXECUTE|[14]
08:13:24.0 (141130980)|HEAP_ALLOCATE|[14]|Bytes:20
08:13:24.0 (141165003)|HEAP_ALLOCATE|[14]|Bytes:20
08:13:24.0 (141483599)|HEAP_ALLOCATE|[14]|Bytes:28
08:13:24.0 (141672561)|FATAL_ERROR|System.NullPointerException: Argument cannot be null.
Trigger.CalculateBalanceOfCustom: line 14, column 1
08:13:24.0 (141699724)|FATAL_ERROR|System.NullPointerException: Argument cannot be null.
Trigger.CalculateBalanceOfCustom: line 14, column 1
08:13:24.141 (141794413)|CUMULATIVE_LIMIT_USAGE
08:13:24.141 (141794413)|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 4 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of Publish Immediate DML: 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
08:13:24.141 (141794413)|CUMULATIVE_LIMIT_USAGE_END
trigger CalculateBalanceOfCustom on Custom_Programming__c (before update)
{
//SQL statement to lookup price
List<PricebookEntry> Pbe = [SELECT UnitPrice FROM PricebookEntry WHERE Product2.Name IN('Custom Development','Tape Drop')AND PriceBook2.Name='DAKCS'];
//New Values for loop
for (Custom_Programming__c cp:Trigger.new){
//Old record values
Custom_Programming__c oldcp = Trigger.oldMap.get(cp.ID);
//If total hours or custom type has not changed then bail
if(cp.Total_Hours__c==null || (cp.Total_Hours__c==oldcp.Total_Hours__c && cp.Custom_Type__c == oldcp.Custom_Type__c))
continue;
//Tapedrop3
if (cp.Custom_Type__c == 'Tape Drop')
{
cp.Testing_Balance__c = pbe[1].UnitPrice + (pbe[0].UnitPrice * cp.Total_Hours__c);
}
//No Billing Bug Fix
else if (cp.Custom_Type__c =='No Billing' || cp.Custom_Type__c =='Bug Fix')
{
cp.Testing_Balance__c = 0;
}
//Everything Else
else
{
cp.Testing_Balance__c =pbe[0].UnitPrice * cp.Total_Hours__c;
}
}
}