Announcement

Collapse
No announcement yet.

How can i fetch the count of opportunities of Contact

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can i fetch the count of opportunities of Contact

    How can i fetch the count of opportunities of Contact using Formula or Report, Based on the count I want to update the customer as Gold, Basic, Platinum status. Can anyone please help?

  • #2
    Hi Ashif Malayil,

    To get the count of opportunities related to a contact using a formula script, you can use the following lines:
    Code:
    $opportunitiesIds = record\findRelatedMany('Contact', id, 'opportunities', 10000, 'createdAt', 'desc');
    $opportunitiesCount = array\length($opportunitiesIds);
    ​​​​

    Comment


    • #3
      I have put the first formula in Contact module, [countOfOpportunities=record\findRelatedMany('Conta ct', id, 'opportunities', 10000);] after mass update it's showing value but when i am creating another opportunity from the contact, the count is not changing even after doing updates in contact also it is showing old value, i want the count should increase each time we are creating a opportunity related to this ocntact?

      Comment


      • #4
        1. Create List Report (with Contact entity type) with a filter shown in the screenshot 1.
        2. Create Scheduled Workflow with Actions > Execute Formula Script with the following formula (screenshot 2):

        HTML Code:
        $opportunitiesIds = record\findRelatedMany('Contact', id, 'opportunities', 10000, 'createdAt', 'desc');
        $opportunitiesCount = array\length($opportunitiesIds);
        description = $opportunitiesCount;
        Replace description in the formula with your field.​
        Attached Files

        Comment

        Working...
        X