You need to sign in to do that
Don't have an account?
Lili Chaves 2
Please Help Me Building a Test Class
Hey there!
I copied @Todd Kadas Trigger code from this forum:
https://developer.salesforce.com/forums/?id=906F00000005G3yIAE
and tweaked it so it would work on SBQQ__Quote__c object in my org. But I have no idea how to build a test class so I can deploy it to prod. Can someone please help?
I copied @Todd Kadas Trigger code from this forum:
https://developer.salesforce.com/forums/?id=906F00000005G3yIAE
and tweaked it so it would work on SBQQ__Quote__c object in my org. But I have no idea how to build a test class so I can deploy it to prod. Can someone please help?
trigger TriggerApprover on SBQQ__Quote__c (before update) { if(trigger.isUpdate){ List<SBQQ__Quote__c> quoteList = [Select id, (Select Id, IsPending, ProcessInstanceId, TargetObjectId, StepStatus, OriginalActorId, ActorId, RemindersSent, Comments, IsDeleted, CreatedDate, CreatedById, SystemModstamp FROM ProcessSteps ORDER BY CreatedDate DESC) From SBQQ__Quote__c WHERE Id IN : Trigger.new]; if(quoteList.size() > 0){ for(SBQQ__Quote__c qt : quoteList){ for(SBQQ__Quote__c qt1 : Trigger.new) { //check copy comment is true if(qt.id == qt1.id && qt1.copy_comment__c) { if (qt.ProcessSteps.size() > 0) { qt1.Approver_Comment__c = qt.ProcessSteps[0].Comments; qt1.copy_comment__c = false; } } } } } } }
Thank you so much for your help. When I run the test I am getting the following error:
“System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SBQQ.QuoteBefore: execution of BeforeInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
Class.SBQQ.QuoteService.defaultQuoteAddressInformation: line 996, column 1
Class.SBQQ.QuoteService.defaultQuoteInformation: line 935, column 1
Trigger.SBQQ.QuoteBefore: line 84, column 1: []”
Any ideas? This is the test class so far:
All Answers
Test class should be like below:
Thanks,
Maharajan.C
Thank you so much for your help. When I run the test I am getting the following error:
“System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SBQQ.QuoteBefore: execution of BeforeInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
Class.SBQQ.QuoteService.defaultQuoteAddressInformation: line 996, column 1
Class.SBQQ.QuoteService.defaultQuoteInformation: line 935, column 1
Trigger.SBQQ.QuoteBefore: line 84, column 1: []”
Any ideas? This is the test class so far:
Please check Apex Class QuoteService ==> and Method defaultQuoteAddressInformation ==> line No 996 in that class. Just satisfy the data for that line.
May be custom settings or any parent records or related records have to be presented before SBQQ__Quote__c record creation.
Thanks,
Maharajan.C
Hi Lili,
Were you able to figure out what the issue was? I am getting the same error when trying to create new CPQ Quote:
Class.SBQQ.QuoteService.defaultQuoteAddressInformation: line 996, column 1 Class.SBQQ.QuoteService.defaultQuoteInformation: line 935, column 1 Trigger.SBQQ.QuoteBefore: line 84, column 1: [] 17:20:29.0 (1352547958)|HEAP_ALLOCATE|[113]|Bytes:410 17:20:29.0 (1352603521)|METHOD_EXIT|[10]|01p050000008dtm|GravityFormsDataService.createRecords(Map<String,ANY>) 17:20:29.0 (1352622210)|SYSTEM_MODE_EXIT|true 17:20:29.0 (1353205112)|METHOD_EXIT|[12]|01p050000008dtm|GravityFormsDataService.processFormData(System.RestRequest) 17:20:29.0 (1353226253)|SYSTEM_MODE_EXIT|false 17:20:29.0 (1353340588)|FATAL_ERROR|System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SBQQ.QuoteBefore: execution of BeforeInsert