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
Brandon MayotteBrandon Mayotte 

Counting number of times an account name is populated in a field

Hi Developer Community!

This is my first post here, so please let me know if I am missing anything.

I am very novice when it comes to development, but what I am looking to build seems possible, so it seems like a nice place to start.

I have a custom relationship field on my opportunity object that tracks the the channel partner associated with the opportunity (Channel_Partner__c).

I want a field on the account object that counts every time an opportunity has that account input.

For example, if three opportunities contained 'Jellyvision Labs" (account name) I would like the account Jellyvision labs to have a field that populates the number 3.

This way, we can track the number of opportunities a channel partner is assocated with without needing to run reporting.

Thanks in advance! I hope this is a great learning opportunity to get me into more Salesforce development work!

Best,

Brandon

kryzkryz
Hi Brandon, 

Welcom to Salesforce. Regarding your question. There is an out of the box functionality that counts all the opportunities related to your Account. All you need to do is the following go to

1. Account's fields
2. Create New Field
3. Select Roll-Up Summary
4. Name your field
5. Then follow the image below and save:

Rollupsummaryfield

Hope this helps! :)
Brandon MayotteBrandon Mayotte
Kryz,

Sorry, maybe I did not explain what I wanted / needed.

Let's say our channel partner is company X.

Company X can resell our product and behalf of our comany, Jellyvision.

Company X sells Company Y our product, and we want to capture that Company X sold this product and we want to track how many times they sold anything at all (they can only sell one product).

Currently, the opportunity would sit with Company Y, because they are the end users, but we need to track in that opportunity that company X was the channel partner.

We have a field 'Channel_Partner__c' that is a account relationship fied where you can only pull in accounts that we have labeled as resller/channel partners.

I need the account object for company X to show populate 1 for selling to company Y, then adding 1 every time company X shows up in any opportunity.

A simple roll-up can only look at opportunities under company X, but no opportunities will be under company X, but instead Company Y.

I hope that cleared things up.

Best,
Brandon
kryzkryz
Hi Brandon,

Got what you mean now. You have created a custom lookup field in Opportunities to lookup to Accounts to associate Channel Partners within an Opp record. Since it's a lookup field, roll up summary does not apply to this field. You don't have the option to convert this field to a master detail relationship field since you are dealing with 2 standard objects, and we all know that is not allowed. You have two options here:

1. Create a custom field that will be populated via Trigger everytime a new opportunity is created // if you have dev skills
2. Create a custom field that will be populated via Process Builder + Flow everytime a new opportunity is created // if you're not a tech consultant and knows how to use PB and Flow. 

I can help you with option 2 because I'm not a technical consultant. Just let me know.

Regards,
Kryzel
Brandon MayotteBrandon Mayotte

Hi Kryzel,

I am pretty comfortable with the PB, but I am really not sure how I can get a flow to accomplish what I am looking for.

I really do feel that building a trigger is going to be the simplest solution, now I just need laern how to build triggers :)

Thanks for your help! If you think that PB + flows would be easy, I am all ears.

Best,
Brandon