-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for Manage HH Page when Undeliverable Address permissions are missing #6749
Conversation
String.valueOf(Contact.SObjectType), String.valueOf(Contact.Undeliverable_Address__c)), | ||
String.valueOf(Address__c.Undeliverable__c) => UTIL_Describe.getFieldLabel( | ||
String.valueOf(Address__c.SObjectType), String.valueOf(Address__c.Undeliverable__c)) | ||
'Undeliverable_Address__c' => undeliverableAddressLabel, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this to avoid additional permissions checking in the front end, the Label will just be blank in cases where permissions are missing.
@@ -615,8 +640,10 @@ public with sharing class HH_Container_LCTRL { | |||
address.MailingState__c = (String)household.get('BillingState'); | |||
address.MailingPostalCode__c = (String)household.get('BillingPostalCode'); | |||
address.MailingCountry__c = (String)household.get('BillingCountry'); | |||
address.Undeliverable__c = (Boolean)household.get( | |||
UTIL_Namespace.StrTokenNSPrefix('Undeliverable_Address__c')); | |||
if (canReadAddressUndeliverable && canReadAccountUndeliverable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this check (and the ones below) also need for canUpdate
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During my testing, I didn't see a case where the User can explicitly set the Undeliverable checkbox through this page. If changing an Address causes a record to be set as Undeliverable, that code should run without sharing via the TDTM trigger, not in the Manage Household logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. If the page doesn't let the user modify the field value, why does the controller allow updating the field value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, I walked away and thought the same thing. Since the Apex is updating values, the User will need that Perm as well. I can't speak to the "why", maybe some of this can be rewritten now that we're allowing use of the form without Undeliverable Address permissions, this first pass was just to get it working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding a Unit test for the new condition?
…thout Undeliverable Address permissions
…rceFoundation/NPSP into feature/fixManageHHPerms
@@ -474,7 +476,9 @@ | |||
con.MailingState = addr.MailingState__c; | |||
con.MailingPostalCode = addr.MailingPostalCode__c; | |||
con.MailingCountry = addr.MailingCountry__c; | |||
con.Undeliverable_Address__c = addr.Undeliverable__c === undefined ? false : addr.Undeliverable__c; | |||
if(con.hasOwnProperty('Undeliverable_Address__c') && addr.hasOwnProperty('Undeliverable__c')){ | |||
con.Undeliverable_Address__c = addr.Undeliverable__c === undefined ? false : addr.Undeliverable__c; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the event that a user doesn't have access/permissions to the Undeliverable field, its value wouldn't get copied here. Wanted to double check to make sure that we're ok with that here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm questioning this now, but the update call on Contact will fail is this field gets changed without permissions, so we'd need to include Update access to the Undeliverable field on Contact in our permissions check.
…ssfully when the permissions error is thrown.
Talked to @lparrott and I just pushed e6a06db to address the spinner not clearing when the permissions error is thrown. FYI @bdvorachek I believed you flagged this when we first looked at this. This should now at least keep the page from being inaccessible whenever the user doesn't have correct FLS. The issue here is that we were referencing a |
…ndeliverable value to a new Address if it was changed
…rceFoundation/NPSP into feature/fixManageHHPerms
OR Field = : accountUndeliverableField | ||
) | ||
]; | ||
for(FieldPermissions fieldPermission : fieldPermissions){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth testing some other combinations, such as:
- Edit Access to the Address.Undeliverable field, but only Read to the Account/Contact fields
- Read Access to the Address.Undeliverable field, but no to the Account/Contact fields
- No Access to the Address.Undeliverable field, but Edit to the Account/Contact fields
There's obviously a lot of permutations. The question is how many of them we want to test to be sure this isn't going to still generate unexpected errors for customers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added one additional test that retains Account.Undeliverable access, since I needed to query that field as part of the test, I'm not sure testing every combination is worth it here, unless we find issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're more concerned with data integrity than unexpected errors in this situation. The problem we were seeing is that the Undeliverable field would get set to an unexpected value if you didn't have permissions to any of the fields, because we relied on field visibility to drive the automated updates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. thanks Luke!
Critical Changes
Changes
Issues Closed
Fixes #6733
Community Ideas Delivered
Features Intended for Future Release
Features for Elevate Customers
New Metadata
Deleted Metadata