Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

Counting Outbound Actions

  • 1.  Counting Outbound Actions

    Posted 12 days ago
    We have an organizational guideline that every inbound customer request (case, opportunity) requires at least two outbound attempts before closing due to non-response. I created 2 rollup fields and 1 calculated field for cases and opportunities. Rollup fields count how many outbound email actions and outbound phone calls. The calculated field adds these together. This is good for automatic counting of these attempts.

    It would be great if these rollup fields were able to count only emails or phone calls to the contact/customer on the record. It's a "dumb smart field". It does not look at whether the email was sent to the contact, just that it was outbound. Has anyone created something they are willing to share that only counts if the contact on the record matches the contact in the email or phone call?

    ------------------------------
    Adam Posegate
    Fox Valley Technical College
    Appleton WI
    ------------------------------


  • 2.  RE: Counting Outbound Actions

    SILVER CONTRIBUTOR
    Posted 12 days ago
    Adam,

    I've done something similar to that, but not exactly what you're describing. This might give you some ideas. The plugin code shown below fires any time an email or phone call activity is created. It checks to see if it's incoming and if the recipient is a system user with a department of Sales. If both conditions are met, then it sets a flag on the sender's contact record.

    I think you could have code similar to this that checks for direction outgoing and checks the recipient against the contact on the case. If both conditions are met then increment the counter field.


    private void EmailAndPhoneSetFlag(Entity entity)
    {
        //instead of using regarding, use the sender
        if (!entity.Contains("from"))
            return;
        var emaildirection = (bool)entity["directioncode"];
        var senders = (EntityCollection)entity["from"];
        var recipients = (EntityCollection) entity["to"];
        bool setflag = false;

        tracingService.Trace("Email Direction: " + emaildirection);
        tracingService.Trace("Senders Count: " + senders.Entities.Count());
        if ((bool)entity["directioncode"] == false) //incoming
        {
        //if any of the recipients are in the Sales department, then continue
        foreach (var recipient in recipients.Entities)
        {
            if (recipient.Contains("partyid"))
            {
                var partyref = (EntityReference) recipient["partyid"];
                tracingService.Trace("PartyRef Logical Name: " + partyref.LogicalName);
                if (partyref.LogicalName == "systemuser")
                    {
                        var user = (from u in serviceContext.CreateQuery("systemuser")
                        where u["systemuserid"].Equals(partyref.Id)
                        select u).FirstOrDefault();

                     if (user != null && user.Id != Guid.Empty)
                     {
                         if (user.Contains("custom_department"))
                             {
                                 if (user["custom_department"] != null && (string) user["custom_department"] == "Sales")
                             {
                                  setflag = true;
                             }
                       }
                  }
              }
          }
      }

      if (setflag)
      {
          foreach (var sender in senders.Entities)
          {
              var partyref = (EntityReference) sender["partyid"];
              tracingService.Trace("PartyRef Logical Name: " + partyref.LogicalName);
              if (partyref.LogicalName == "contact" || partyref.LogicalName == "lead")
                  crmHelper.SetFlag(partyref, ProspectLead, DateTime.Now);
           }
        }
      }
    }

    #customerengagement #technical ​​

    ------------------------------
    Andy Arndt
    Minitab, Inc.
    State College PA
    ------------------------------



  • 3.  RE: Counting Outbound Actions

    Posted 12 days ago
    Thank you - I will take a look at this and see what I can do.

    ------------------------------
    Adam Posegate
    Fox Valley Technical College
    Appleton WI
    ------------------------------