utmccombs / AffiliationSecurity

HEDA Affiliation-Based Security for Salesforce
BSD 3-Clause "New" or "Revised" License
8 stars 4 forks source link

New install APEX exception - NullPointerException #2

Open bovardit opened 4 years ago

bovardit commented 4 years ago

After installing and attempting to create the first affiliation security rule, I receive the following error.

TDTM_AffiliationSecurityRule: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object Class.AFFL_SecurityRule_TDTM.run: line 131, column 1 Class.hed.TDTM_TriggerHandler.runClass: line 145, column 1 Class.hed.TDTM_TriggerHandler.run: line 75, column 1 Class.hed.TDTM_Global_API.run: line 61, column 1 Trigger.TDTM_AffiliationSecurityRule: line 33, column 1

Do you have any ideas as to what we can do to troubleshoot this?

bovardit commented 4 years ago

Interestingly, if I uncheck "Primary" in the new rule it allows me to create it without issue.

kyleschmid commented 4 years ago

@bovardit The class is having trouble getting to the Administrative Account on the related Contact for one of the Affiliations. Take a look at your data and see if there are any Affiliations without Contacts or that have Contacts without Accounts: SELECT COUNT(Id) FROM hed__Affiliation__c WHERE hed__Contact__c = null OR hed__Contact__r.AccountId = null

bovardit commented 4 years ago

Thanks @kyleschmid, I just made it past that and found an affiliation without a contact record. Deleting that resolved that issue. Now I'm running up against an issue of >10001 affiliations that need updated when creating a new AffiliationSecurityRule. Any recommendations there? After choosing the role/status/organizatoin, I receive "TDTM_AffiliationSecurityRule: System.LimitException: hed:Too many DML rows: 10001"

kyleschmid commented 4 years ago

@bovardit The trigger attempts to update any matching affiliations whenever a rule is created/updated. If your rule is matching against too many affiliations, you'll have to switch off the trigger and manually make the updates the trigger would have made. The other option is to write a batch class that takes care of doing the backfill.