Skip to main content

Timeline for Test failing for Apex Trigger

Current License: CC BY-SA 3.0

17 events
when toggle format what by license comment
Jul 7, 2014 at 18:27 vote accept TimMilazzo
Jul 7, 2014 at 18:00 answer added cropredy timeline score: 1
Jul 7, 2014 at 17:19 comment added TimMilazzo Thank you @crop1645! Now I'm getting to my assertion at the bottom of the test, but it is failing. You're the hero today if you know that one too.
Jul 7, 2014 at 16:47 comment added cropredy Your problem is here: if (o.Request_PubApproval__c && !oldopp.Request_PubApproval__c && o.Account.Account_Region__c <> 'North America' && o.Account.Account_Region__c <> '' && o.Account.Account_Region__c <> null). The field o.account.account_region__c is not in scope for trigger.new. Only the Opportunity fields are in scope for Trigger.new. You'll need to query to get the Account fields via the lookup relationships - be sure to bulkify the lookup query
Jul 7, 2014 at 16:07 comment added TimMilazzo OK so learning this Debugging game as I go. I've narrowed the problem down to this: both the test class and trigger see the Account's Account_Region__c field as null, even though I set it as 'EMEA' in my test class. Does anyone know why it might later be shown as null? @crmprogdev?
Jul 7, 2014 at 15:39 comment added TimMilazzo Can someone share how I could successfully debug this trigger's first If() statement?
Jul 7, 2014 at 14:53 comment added TimMilazzo Hi crmprogdev - through the Developer Console's test coverage, it looks like the trigger isn't covered past the first if() statement, so one of those conditions is not true for the test. That's where I'm stumped, as "Request_PubApproval__c" should be newly true, and the region in the test isn't one that's excluded.
Jul 7, 2014 at 14:48 comment added crmprogdev Ahh, that explains it! I edited my comment when I saw it revert. Good to know so many people are on the job! :)
Jul 7, 2014 at 14:36 review First posts
Jul 7, 2014 at 15:10
Jul 7, 2014 at 14:34 comment added Samuel De Rycke crmprogdev, I had accidentally approved the suggested edit. Haved rolled back to your edit.
Jul 7, 2014 at 14:34 comment added Bforce you query to get the opportunity should be like this, opp = [select id, Request_PubApproval__c, Name, ownerID from Opportunity where name = 'pubpubpubApprovalTest' Limit 1]
Jul 7, 2014 at 14:32 history rollback Samuel De Rycke
Rollback to Revision 2
Jul 7, 2014 at 14:31 comment added crmprogdev Hi Tim! Welcome to Salesforce.StackExchange. I've formatted the code for your trigger so it displays properly (select it, then hit the {} for preformatted text) or space each line over 4 spaces. Have you tried adding debug statements to see where your code isn't working?
S Jul 7, 2014 at 14:28 history suggested SalesforceAspiration CC BY-SA 3.0
Placed the codes in code block
Jul 7, 2014 at 14:24 review Suggested edits
S Jul 7, 2014 at 14:28
Jul 7, 2014 at 14:23 history edited crmprogdev CC BY-SA 3.0
formatted unformatted sections of code
Jul 7, 2014 at 14:19 history asked TimMilazzo CC BY-SA 3.0