Skip to content
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

Merged
merged 19 commits into from
Dec 16, 2021

Conversation

lparrott
Copy link
Contributor

Critical Changes

Changes

  • We fixed an issue with the Manage Household page where the page wouldn't load without permissions to Undeliverable Address fields.

Issues Closed

Fixes #6733

Community Ideas Delivered

Features Intended for Future Release

Features for Elevate Customers

New Metadata

Deleted Metadata

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,
Copy link
Contributor Author

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@force2b force2b left a 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?

@@ -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;

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?

Copy link
Contributor Author

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.
@daniel-fuller
Copy link
Contributor

daniel-fuller commented Nov 29, 2021

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 self variable in the setCallback() and that variable was not declared so when the page loaded an unhandled aura exception was thrown with a message that read, "self.reportError is not a function", and this is the error which kept the spinner overlay from clearing.

OR Field = : accountUndeliverableField
)
];
for(FieldPermissions fieldPermission : fieldPermissions){
Copy link
Contributor

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.

Copy link
Contributor Author

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.

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.

Copy link
Contributor

@daniel-fuller daniel-fuller left a 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!

@npsp-reedestockton npsp-reedestockton merged commit d521858 into main Dec 16, 2021
@npsp-reedestockton npsp-reedestockton deleted the feature/fixManageHHPerms branch December 16, 2021 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Manage Household Page Fails to Load If Customer Does Not Have Access to New Undeliverable Address Fields
7 participants