function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Marco RispoliMarco Rispoli 

Best way to approach updates to a field affecting multiple account records

I am trying to figure out what would be the best way to approach this problem:
In the account table (for all record types) we have 4 email fields: email, email2, email3 and email4. 
I need to be able to flag these emails as "unsubscribed" so that when our call center pulls up a customer profile they can see if the customer chose to pull their email(s) from subscribing to our mailing list
An email can be shared across multiple accounts (our users have more than one account with us. We are working towards changing that but it will not change in the foreseeable future). 

So if I receive a feed with a list of emails and the instruction to unsubscribe them I want to update the flag for that email across multiple accounts.
At the same time if the customer updates the email status in one of his/her account I want the status change for that email to be reflected in all accounts that have that email. 

What would be the best way to approach this?

Option 1 - have an object that contains the list of all emails with status "unsubscribed". 
Pros - I have only one place to update or maintain the status flag
Cons - every time I pull up the account table the account needs to join to this object, pull up the status and display accordingly

Option 2 - create the flag direclty into the account object
Pros - simple to display (it's just part of the object) and if it's a feed update it's also not hard to do
Cons - I would have to code a trigger that would update the status in all records that have that email, for that specific email.

In the "traditional" world (Java/Oracle or any similar flavor of that) I'd create a seprate object and then just FK to it from the account table.

But I am aware that SF is not always "traditional" when it comes to these types of scenarios ... sometimes the usual approach doesn't always work best. 

Any guidance or thoughts about which approach works best in SalesForce? 

Any help would be greatly appreciated.

Thank you!!!

M
Best Answer chosen by Marco Rispoli
GauravGargGauravGarg

Hi Marco,
 
I was thinking for this approach, as we have implemented something like Parent Account  <--> Account (parent/child) combination in our org. The best part of using this combination is that, we do need to look for code side whenever we need any update on child via Parent Account i.e. Account to Account update. 

I can elaborate this in something like:

Currently Salesfoce provide us Standard Account object. Now we will use Single Account Object into two records.
1. Parent Account
2. Child Accounts
Now to develop this approach, we will separate account records using Record Types.

Child Account records are the one, which you already have it in your org, you need to create recordtype and Data Migration for Parent Account for all those child account having similar features. 

Now, as we have Parent account and Child account, we will create one checkbox (email enabled) on parent account and the formula checkbox on child account level which will be (parent_Account__r.email_enabled).

Through above approach, I think your work would be very much easy to develop as well as to manage it in future. 

Let me know if you need more insight or help to implement this functionality in your org. You can also contact me directly on below details.

Thanks,

Gaurav
Email: gauravgarg.nmims@gmail.com

All Answers

GauravGargGauravGarg

Hi Marco,

Approch #2: will be more beneficial and will works effectively and easily. 
This approach will work in both the cases with just few lines of code and that too simpler ones.

You can try one more approach, if possible in you business scenario:
1. Create parent account of all account  having same customer.
2. Add flag on parent account. 
3. If customer need flag to be "true", it will be auto-populated via formula field on child account and vice-versa.

Pleae let me know if you need more insight on this.

Thanks,
Gaurav
Email: gauravgarg.nmims@gmail.com

Marco RispoliMarco Rispoli
Guarav, thank you so much for replying!!

As a matter of fact your suggested approach using the formula field is something I didn't think about ... and it actually sound excatly like what I need ... 

Any chance you can elaborate? if not I'll try to look it up by myself in the online docs.

Thank you!!!

M
GauravGargGauravGarg

Hi Marco,
 
I was thinking for this approach, as we have implemented something like Parent Account  <--> Account (parent/child) combination in our org. The best part of using this combination is that, we do need to look for code side whenever we need any update on child via Parent Account i.e. Account to Account update. 

I can elaborate this in something like:

Currently Salesfoce provide us Standard Account object. Now we will use Single Account Object into two records.
1. Parent Account
2. Child Accounts
Now to develop this approach, we will separate account records using Record Types.

Child Account records are the one, which you already have it in your org, you need to create recordtype and Data Migration for Parent Account for all those child account having similar features. 

Now, as we have Parent account and Child account, we will create one checkbox (email enabled) on parent account and the formula checkbox on child account level which will be (parent_Account__r.email_enabled).

Through above approach, I think your work would be very much easy to develop as well as to manage it in future. 

Let me know if you need more insight or help to implement this functionality in your org. You can also contact me directly on below details.

Thanks,

Gaurav
Email: gauravgarg.nmims@gmail.com

This was selected as the best answer